How to set field value with beforeload userevent script for existing itemfulfillment??

I want to setValue on the transaction body field for existing records, that value comes from query results. I tried with userevent beforeLoad function but not worked. is this scenario works with userevent beforeload script?

Rookie Asked on February 9, 2023 in SuiteScript.
Add Comment
1 Answer(s)

Hi,

When do you want this to happen? Is it based on a user doing something? Or on a scheduled basis?

Thanks,

Chris

Intermediate Answered on February 9, 2023.

Hello chris,
Thank you for your quick responce.

my script looks like below.

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define([‘N/record’,’N/query’,’N/currentRecord’,’N/search’], function(record,query,currentRecord,search) {
    function beforeLoad(context) {
      if (context.type == ‘view’) {
        var iffid = context.request.parameters.id;
        // var currentRecord = record.load({
        //   type: ‘itemfulfillment’,
        //   id: iffid,
        //   isDynamic: true
        // });
        strQuery = “select  my_custrecord_field from My_CUSTOMRECORD where my_customrecord_field = “+ iffid
        results = query.runSuiteQL({
            query: strQuery
        });
        log.debug({title: ‘strQuery  results’, details: results});
        record.setValue({
            fieldId: ‘custbody111’,
            value: results
        });
      }
    }
    return {
      beforeLoad: beforeLoad
    };
  });
on February 9, 2023.

Hi,

Are you wanting to store the value in the filed or just display to users?

Thanks,

Chris

on February 9, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor