Monday, May 6, 2019

Department Field from Sales Order on Fulfilment Record

The Department field can not be shown on Item Fulfillment - there is an existing enhancement. Here is a way how to display department information from Sales Order on Item Fulfillment form.


Create custom transaction body field ('custbody15' in example script) 

  • Type = Free-Form Text 
  • Store Value = checked 
  • Applies To = Item Fulfillment 
  • Display Type = Main 
  • click Save

Create new client side SuiteScript (it will read the Department name
and place it into custom field we created in previous step) 

  • trigger on pageInit 

Here is a sample of this script:

function beforeLoadIF (type){	var SalesOrderID = nlapiGetFieldValue('createdfrom');	// get the ID of Sales Order what Item Fulfillment is created from	var SalesOrderRec = nlapiLoadRecord('salesorder', SalesOrderID);	// load the Sales Order	var SalesOrderDepID = SalesOrderRec.getFieldValue ('department');	// read ID of department from Sales Order	var DepartmentRec = nlapiLoadRecord('department', SalesOrderDepID);	// load Department record		var DepartmentName = DepartmentRec.getFieldValue ('name');	// read the name of department    nlapiSetFieldValue('custbody15',DepartmentName, false);    // write the name of department into custom field in Item Fulfillment}
Department field on the source Sales Order must be filled. 
This approach works for creating or editing of single Item Fulfillment but not for bulk fulfilling.

No comments:

Post a Comment