'How can I eliminate having to not repeat the same code
I have a script that adds items to a Netsuite record. In this case 22 items needs to be added but the value lines in the below are different for each item. Rather than having to repeat the same lines over and over again is there a better way to do this.
Code below:
rec.setCurrentSublistValue(
{
sublistId: 'item',
fieldId: 'item',
value: 1261,
forceSyncSourcing: true
} )
// Add item description
rec.setCurrentSublistValue(
{
sublistId: 'item',
fieldId: 'description',
value: 'Charge Description'
} )
// Add item quantity
rec.setCurrentSublistValue(
{
sublistId: 'item',
fieldId: 'quantity',
value: 1,
forceSyncSourcing: true
} )
// Add Estimated Unit Cost F/X
rec.setCurrentSublistValue(
{
sublistId: 'item',
fieldId: 'custcol_est_unit_cost_fx',
value: handlingBuy,
forceSyncSourcing: true
} )
// Add Margin
rec.setCurrentSublistValue(
{
sublistId: 'item',
fieldId: 'custcol_orig_rate',
value: handlingSell,
} )
// Commmit The Item
rec.commitLine(
{
"sublistId": "item"
} );
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
