I have a before-load user event script that pre se...
# suitescript
s
I have a before-load user event script that pre set some customization, till now it was only used for creating new kit items will that not work if I'm editing the old record?
Copy code
var record = context.newRecord;
s
In a user event script, oldRecord newRecord just refer to the state of a record before or after some chages have been made. On create, there is only newRecord, and on delete there is only oldRecord. Every other action has both. So, even though it is an old record (in the sense that it was created a while ago) it will still have context.newRecord, however, that will contain the changes being made, not the data originally there before the changes.
s
if the user is editing the record this should still work
Copy code
var record = context.newRecord;

    record.setValue({ fieldId: "subsidiary", value: 2 });
    record.setValue({ fieldId: "taxschedule", value: "1" });
    record.setValue({ fieldId: "custitem_fa_amz_flag01", value: 1 });
s
yes, though if the user actually changed any of those fields, your script will overwrite those changes
s
this is a before load
s
okay, that will work differently then
In a before load script, you can only edit data upon creation of a record, according to NetSuite's documentation: https://netsuite.custhelp.com/app/answers/detail/a_id/10635 • 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.
in order to make it work for old/existing records, you would need to have a before submit entry point as well