Sunday, December 30, 2018

User Event Before Load does not support sourcing of fields/items

When fields or item sublist fields are being set on BeforeLoad User Event script, the sourcing is not set.

As an example, the item fields will not load the selections for the following (to name a few):
- Units of Measurement
- Tax Codes
- Locations

SOLUTION:

1. Set the fields/items instead on a Client Script.
2. Or copy the item on ReCalc function should they want to retain the Before Load script.

Sample Code snippet:

--------------------------------

 function reCalcItem()
 {
  if (nlapiGetRecordType()=='purchaseorder')
  {
   var cFlag = nlapiGetLineItemValue('item', 'custcol_item_flag', currentLine);

   if (cFlag=='F')
   {
    var currentLine = nlapiGetCurrentLineItemIndex('item');

    var currentItem = nlapiGetLineItemValue('item', 'item', currentLine);
    var currentRate = nlapiGetLineItemValue('item', 'rate', currentLine);

    nlapiSetCurrentLineItemValue('item','item',currentItem,false,true);
    nlapiSetCurrentLineItemValue('item','rate',currentRate,false,true);
    nlapiSetCurrentLineItemValue('item','custcol_item_flag','T',false,true);

    nlapiCommitLineItem('item');
   }
    }
 }

--------------------------------
- 'custcol_item_flag' is an added custom Transaction column field deployed on Purchase Order

NOTE: Sourcing in Before Load scripts is currently filed as Enhancement #197591.

No comments:

Post a Comment