Scenario
A User Event script is loading the Item Fulfillment record dynamically and it appends details to the Attention (id: attention) field found in the Address subrecord. Appending values to the said field in the record level will automatically check the Override (id: override)checkbox that is also a part of the Address subrecord of the Item Fulfillment and set the Address Select (id: shipaddresslist) dropdown to “– Custom –“. With this behavior, changes in Attention field will not appear in the Address (id: shipaddress) text area.
Solution
As an alternate solution to show the changes made from the Attention field to Address text area, create a User Event script that has an After Submit function and deploy it in the Item Fulfillment record. Inside the After Submit function, create the logic of the script in such a way that it will automatically untick the Override checkbox if it is checked. You may follow the steps below to create the logic of the script.
- Use the After Submit function of the User Event script
- Load the Item fulfillment record
- Access the subrecord
- Check if the value of Override checkbox is “T”/true.
- If Override checkbox is “T”/true, then set it to “F”/false.
- Commit the subrecord
- Save the record
SAMPLE CODE
SuiteScript 2.0:
function afterSubmit(scriptContext) {
var itemFulfillment = record.load({
type: record.Type.ITEM_FULFILLMENT,
id: scriptContext.newRecord.id
});
var sub = itemFulfillment.getSubrecord({
fieldId: "shippingaddress"
});
if(sub.getValue({fieldId: "override"})){
log.debug({
title: "OVERRIDE",
details: "Setting to False"
});
sub.setValue({
fieldId: "override",
value: false
});
}
else {
log.debug({
title: "OVERRIDE",
details: "Value is false."
});
}
itemFulfillment.save();
}