Tuesday, May 14, 2019

Item Fulfillment showing Total Amount of Lines Using SuiteScript

Item Fulfillment showing Total Amount of Lines Using SuiteScript
  1. Create a new custom transaction column field according to SuiteAnswers article (13937): "Display the Total Amount for Each Line in the Item Fulfillment". Enter the field ID, e.g. "lineamount".
  2. Create a new Transaction Body Field
    1. Navigate to Customization > Transaction Body Fields > New
    2. Label the field
    3. Set the ID field e.g. "totalitemamount"
    4. Set Type to Currency
    5. Store Value set as unchecked
    6. Applies To subtab > Item Fulfillment checked
    7. Display subtab > Subtab set to Items
    8. Display subtab > Display Type set as Inline Text
    9. Click Save
  3. The New Script
    1. Create a new User Event script as follows
              function eventBeforeLoad(type, form, request){                  var lineamount = 0; //set the counter          var lines = nlapiGetLineItemCount('item'); //access the items tab                   // use for loop to go through all the items on item subtab 	          for(var i = 1; i <= lines; i++){ 		            // sum the amount of the line  		            lineamount = lineamount + parseFloat(nlapiGetLineItemValue('item', 'custcollineamount'  , i));	 	          }         	 	          // save the value into the custom body field 	          nlapiSetFieldValue('custbodytotalitemamount', lineamount);           }
    2. Deploy the script on Item Fulfillment page
Review any Item Fulfillment record and make sure that the amount of lines is populated in the new custom field on Items subtab

No comments:

Post a Comment