Rehan
12/10/2019, 2:27 AMvar orgLocation = itemRs[i].getValue({ name : 'inventorylocation'});
var orgQuantity = itemRs[i].getValue({ name : 'binonhandcount'});
var itemId = itemRs[i].getValue({ name : 'internalid'});
var sourceBin = itemRs[i].getValue({ name : 'binnumber'});
var inventoryXfer = record.create({
type : record.Type.INVENTORY_TRANSFER,
isDynamic : true
});
inventoryXfer.setValue({ fieldId : 'location', value : orgLocation });
inventoryXfer.setValue({ fieldId : 'department', value : transferDept});
inventoryXfer.setValue({ fieldId : 'transferlocation', value : masterLocationParam });
inventoryXfer.selectLine({ sublistId : 'inventory', line : 0});
inventoryXfer.setCurrentSublistValue({
sublistId: 'inventory',
fieldId : 'item',
value : itemId,
});
inventoryXfer.setCurrentSublistValue({
sublistId: 'inventory',
fieldId : 'itemcount',
value : orgQuantity,
})
inventoryXfer.setCurrentSublistValue({
sublistId: 'inventory',
fieldId : 'quantityonhand',
value : orgQuantity,
})
inventoryXfer.setCurrentSublistValue({
sublistId: 'inventory',
fieldId : 'tobins',
value : bin,
})
inventoryXfer.commitLine({ sublistId: 'inventory'});
inventoryXfer.save();
Alex Hirota
12/10/2019, 2:32 AMinventoryXfer.selectNewLine({sublistId:'YourID'})
perhaps?Rehan
12/10/2019, 2:38 AMbattk
12/10/2019, 2:45 AMbattk
12/10/2019, 2:53 AMDmitry Masanov
12/10/2019, 8:50 AMRehan
12/10/2019, 2:23 PMRehan
12/10/2019, 2:23 PMDmitry Masanov
12/10/2019, 2:27 PMfunction copyInventoryDetails(sourceRecord: record.ClientCurrentRecord, targetRecord: record.ClientCurrentRecord) {
for (let itemLineNumber = 0; itemLineNumber < sourceRecord.getLineCount({sublistId: 'item'}); itemLineNumber++){
// newScriptResult.logs.push(`Working with ITEM line ${itemLineNumber}`);
sourceRecord.selectLine({sublistId: 'item', line: itemLineNumber});
targetRecord.selectLine({sublistId: 'item', line: itemLineNumber});
const oldInventoryDetails = sourceRecord.getCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail',
});
const newInventoryDetails = targetRecord.getCurrentSublistSubrecord({sublistId: 'item', fieldId: 'inventorydetail'});
const serialNumbersInOldRecord = oldInventoryDetails.getLineCount({sublistId: 'inventoryassignment'});
// const serialNumbersArray = ['ACCC8EB54B87', 'ACCC8EB5578F'];
for (let serialNumberNumber = 0; serialNumberNumber < serialNumbersInOldRecord; serialNumberNumber++) {
oldInventoryDetails.selectLine({sublistId: 'inventoryassignment', line: serialNumberNumber});
const oldQuantity = oldInventoryDetails.getCurrentSublistValue({sublistId: 'inventoryassignment', fieldId: 'quantity'});
const oldSerialNumber = oldInventoryDetails.getCurrentSublistText({sublistId: 'inventoryassignment', fieldId: 'issueinventorynumber'});
console.log(`Old serial number is "${oldSerialNumber}" with quantity of ${oldQuantity}`);
// const oldSerialNumber = serialNumbersArray[serialNumberNumber];
newInventoryDetails.selectNewLine({sublistId: 'inventoryassignment'});
newInventoryDetails.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
value: oldQuantity
});
newInventoryDetails.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'receiptinventorynumber',
value: oldSerialNumber,
});
console.log(`Commiting serial number ${serialNumberNumber}: ${oldSerialNumber}`);
newInventoryDetails.commitLine({
sublistId: 'inventoryassignment',
});
console.log(`Successfully commited serial number ${oldSerialNumber} in line ${itemLineNumber}, position ${serialNumberNumber}`);
}
targetRecord.commitLine({sublistId: 'item'});
}
}
Dmitry Masanov
12/10/2019, 2:28 PMDmitry Masanov
12/10/2019, 2:29 PMRehan
12/10/2019, 2:52 PMRehan
12/11/2019, 2:48 AM