You may find these errors
You have entered an Invalid Field Value 13028543 for the following field: purchaseorder
Please enter value(s) for: PO, Item
Please enter value(s) for: Item
According to the Schema, the mandatory fields are purchaseorder, shipmentitem. Yes, that purchaseorder refers the internalid of purchase order, but the shipmentitem does not mean the item ids of the item on the PO – it’s actually lineuniquekey of PO items!
Here is a working example and all you need to do is to replace ids with records in your environment and add more fields if needed.
let recObj = record.create({
type: 'inboundshipment',
isDynamic: true
})
var purchaseorderSearchObj = search.create({
type: "purchaseorder",
filters:
[
["type", "anyof", "PurchOrd"],
"AND",
["internalid", "anyof", poId],
"AND",
["mainline", "is", "F"],
"AND",
["taxline", "is", "F"]
],
columns:
[
search.createColumn({ name: "lineuniquekey", label: "Item" })
]
});
let line = 0
purchaseorderSearchObj.run().each(function (result) {
recObj.selectLine({ sublistId: 'items', line: line })
recObj.setCurrentSublistValue({ sublistId: 'items', fieldId: 'purchaseorder', value: poId})
recObj.setCurrentSublistValue({ sublistId: 'items', fieldId: 'shipmentitem', value: result.getValue({name: 'lineuniquekey'}) })
recObj.commitLine({ sublistId: 'items' })
line++
return true;
});
const inShpId = recObj.save()
Comments
Nice! That was useful