How to create inventorydetail in Standard Mode?

Hi all,

My basic goal is to create a “backward” Transfer Order for a Transfer Order given. So, just need to swap Location From and Location TO

What I do is I copy the first Transfer Order:

var newTransferOrder = record.copy({type: Type.TRANSFER_ORDER, id: currentRecordId, isDynamic: false});

and simply swap locations:

newTransferOrder.setText({fieldId: 'location', text: previousOrderLocationTo, fireSlavingSync: false, ignoreFieldChange: true});

newTransferOrder.setText({fieldId: 'transferlocation', text: previousOrderLocationFrom, fireSlavingSync: false, ignoreFieldChange: true});

The problem here is that all inventory details in new Transfer Order get purged and I need to re-create them. I heard that it was only possible to set inventorydetails in Standard mode.

When I try to get inventory details object in standard mode:

newInventoryDetails = newTransferOrder.getSublistSubrecord({sublistId: 'item', fieldId: 'inventorydetail', line: itemLineNumber});

i got the Unexpected Error if the inventory details is empty (blue arrow). If there is an inventory details object for the item line (green arrow), it works with no errors.

Can someone please point me at the right direction on how to perform that in SS 2.0?

Thank you!

Rookie Asked on November 6, 2019 in SuiteScript.
Add Comment
1 Answer(s)

Ok, I think I managed to make it work in dynamic mode instead:

const serialNumbersArray = ['SN1', 'SN2'];
for (let serialNumberNumber = 0; serialNumberNumber < serialNumbersInOldRecord; serialNumberNumber++) {
oldInventoryDetails.selectLine({sublistId: 'inventoryassignment', line: serialNumberNumber});
newInventoryDetails.insertLine({sublistId: 'inventoryassignment', line: serialNumberNumber});
sublistId: 'inventoryassignment'

sublistId: 'inventoryassignment',
fieldId: 'quantity',
value: 1

sublistId: 'inventoryassignment',
fieldId: 'receiptinventorynumber',
value: serialNumbersArray[serialNumberNumber]
console.log(`Commiting serial number ${serialNumberNumber}`);
sublistId: 'inventoryassignment',

console.log('Commiting item line');
targetRecord.commitLine({sublistId: 'item'});
Rookie Answered on November 6, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor