RE: In SS2.x, can you set a field value in beforeLoad of a User Event script?
Answered
Hello!
So in a User Event script in the beforeLoad function I need to set a custom Transaction Body Field value, like this:
var newRecord = context.newRecord; newRecord.setValue({ fieldId: 'custbody_my_custom_field', value: true // or false });
Logging the result of the above, I can see the value change, but it does not persist through the entire page load, and always returns to the default state. I have ‘Store Value’ checked on the field’s setup. So, is it just not possible to set a field value in beforeLoad and have that value persist?
Thanks for any help!!
What event mode you want to change the specific custom field.
I tried to change the custom field value in “view” event mode and successfully changed. Using this code block
var
newRecord = context.newRecord;
newRecord.setValue({
fieldId:
'custbody_my_custom_field'
,
value: true
// or false
});
return newRecord
.save();