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?
Hi,
When do you want this to happen? Is it based on a user doing something? Or on a scheduled basis?
Thanks,
Chris
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
};
});
Hi,
Are you wanting to store the value in the filed or just display to users?
Thanks,
Chris