Friday, October 12, 2018

Dynamically Set the Price Level of Items on Orders Coming from the Web Store using Scripts

To dynamically set the price level of items on orders coming from the Web Store, users must use an internal form as the Scripting Template of their Web Store. To use an internal form as the Scripting Template, follow these steps:

1. Navigate to Customization > FormsTransaction Forms.
2. Click Customize across Standard Sales Order - Cash Sale.
3. Type desired name of the form on the Name field.
4. Click Save to save the form. 
5. Navigate to Setup > Site Builder > Setup Web Site.
6. Click Edit across desired web site.
7. On the Scripting Template (Credit Card) field, select the newly created form.
8. Click Save to save the changes to the Web Site.

Users may now use either user event or form-based client-side scripts to change the price level of items in the orders. The following is a sample script function to set the price level of each item on the item sublist:

function onChange(){
var itemCount = nlapiGetLineItemCount('item');
for(var i = 1; i <= itemCount; i++){
nlapiSelectLineItem('item',i);
nlapiSetCurrentLineItemValue('item','price','1',true,true);
nlapiCommitLineItem('item');
}
}

Note:  The item price level cannot be changed using scripts on default external forms because said field is only available on the item machine of internal forms.

No comments:

Post a Comment