RE: In SS2.x, can you set a field value in beforeLoad of a User Event script?

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!!

 

mreser Rookie Asked on September 16, 2019 in SuiteScript.
Add Comment
3 Answers
Best answer

Per Help:

/app/help/helpcenter.nl?fid=section_N2962963.html

 

  • Data cannot be manipulated for records that are loaded in beforeLoad scripts. If you attempt to update a record loaded in beforeLoad, the logic is ignored.
  • Data can be manipulated for records created in beforeLoad user events.

Looks like you cannot set a field using Before Record Load on existing records. I did a quick test using a Before Load UE script and it let me change a custom field value on a “new” sales order but not when I’m trying to edit an existing sales order.

 

Beginner Answered on September 16, 2019.

Yeah, thanks. battk on the Slack channel linked to those docs and unfortunately, this can’t be done on an existing record, which mine is. Some people are suggesting using a client script with the user event script. I’ll need to goto the docs… for a warning message I am having difficulty passing data from a User Event to Client already. Not being able to manipulate data on an existing record on BeforeLoad seems like a needless restriction, but . . .

on September 16, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.