Saturday, February 9, 2019

Create a Sales Order with an Item that has a Billing Schedule using Scripting

1. Navigate to Customization > Scripting > Scripts > New > click User Event.
2. On BEFORE SUBMIT FUNCTION field, type the function
name of the script below: createSalesOrderAfterCreatingAnEvent

3. Click on the Plus(+) button next to the SCRIPT FILE field to upload the script below.

 

Note:
1. Open any Script Editor (i.e. SuiteCloud IDE,
Notepad++, etc...) and copy the script below then Save As "JavaScript" file (.js)

 

 

function createSalesOrderAfterCreatingAnEvent()                                                                             

{

var record = nlapiCreateRecord('salesorder', {recordmode: 'dynamic'});               //create a Sales Order                        

 

record.setFieldValue('entity','5264');                                                                    //5264 is an internal ID of a customer

 

// add the first item

record.selectNewLineItem('item');

record.setCurrentLineItemValue('item', 'item', 944);                                            //944 is an internal ID of an item

//record.setCurrentLineItemValue('item', 'quantity', 2);

record.setCurrentLineItemValue('item', 'billingschedule', 36);                               //36 is the internal ID of 36 months on the Billing Schedule

record.commitLineItem('item');

 

var SubmitIt=nlapiSubmitRecord(record,true);                                                    //save Sales Order

 

}

 

 

4. Click Save and Deploy.

  • Applies To: Sales Order
  • Audience tab > Roles > Select All = Check
5. Click Save

 

 

No comments:

Post a Comment