Item Fulfillment – Address Update

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.

  1. Use the After Submit function of the User Event script
  2. Load the Item fulfillment record
  3. Access the subrecord
  4. Check if the value of Override checkbox is “T”/true.
  5. If Override checkbox is “T”/true, then set it to “F”/false.
  6. Commit the subrecord
  7. 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();

}

Leave a comment

Your email address will not be published. Required fields are marked *