Hopefully someone can help me with this error, i followed all the step to do Inventory Detail. This is the error i get, I'm trying to create a inventory detail for inventory transfer but it throws me an error. this is to transfer from a bin location to a non-bin location
{
type: "error.SuiteScriptError",
name: "INVALID_FLD_VALUE",
message: "You have entered an Invalid Field Value 1449 for the following field: binnumber"
}
I have tried every solution i can find on the internet but i still get "INVALID_FLD_VALUE", below is one the solution I've used. I've tried using isDynamic = true, but i still got the same error. I've checked the binnumber and i can do manual Inventory Transfer and it seems that the binnumber is correct but every time i tried to run this script it always display "INVALID_FLD_VALUE". The binnumber has a select type is there something else i need to do?
var inventoryTransfer = RECORDMODULE.create({
type: RECORDMODULE.Type.INVENTORY_TRANSFER,
isDynamic: true,
defaultValues: null
});
inventoryTransfer.setValue({
fieldId: "location",
value: fromlocation,
});
inventoryTransfer.setValue({
fieldId: "transferlocation",
value: tolocation,
});
inventoryTransfer.setValue({
fieldId: "trandate",
value: new Date(),
});
inventoryTransfer.setValue({
fieldId: "memo",
value: 'test IT'
});
inventoryTransfer.setValue({
fieldId: "custbody6",
value: presta_order_id
});
// Loop through each item and add it to the inventory transfer
processItems.forEach(function (item, key) {
log.debug('item', item);
if (item.id) {
inventoryTransfer.selectNewLine({
sublistId: "inventory",
});
inventoryTransfer.setCurrentSublistValue({
sublistId: "inventory",
fieldId: "item",
value: item.id
});
inventoryTransfer.setCurrentSublistValue({
sublistId: "inventory",
fieldId: "adjustqtyby",
value: item.quantity
});
inventoryTransfer.setCurrentSublistValue({
sublistId: "inventory",
fieldId: "quantityonhand",
value: itemDetails.data[0].values.quantityonhand
});
// Create inventory detail (assignments)
var inventoryDetail = RECORDMODULE.create({
type: RECORDMODULE.Type.INVENTORY_DETAIL,
});
var lineCount = inventoryDetail.getLineCount({ sublistId: 'inventoryassignment' });
log.debug('line count', lineCount);
inventoryDetail.insertLine({
sublistId: 'inventoryassignment',
line: 0
});
inventoryDetail.setSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'binnumber',
value: binId, // Replace with actual bin internal ID
line: 0
});
inventoryDetail.setSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantityavailable',
value: itemDetails.data[0].values.quantityonhand, // Ensure this matches the transferred quantity
line: 0
});
inventoryDetail.setSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
value: item.quantity, // Ensure this matches the transferred quantity
line: 0
});
log.debug('inventoryDetail',inventoryDetail);
// // Commit the inventory assignment line
inventoryDetail.save({
sublistId: 'inventoryassignment'
});
}
});
// Commit the line for the item
inventoryTransfer.commitLine({
sublistId: 'inventory'
});
You would not generally create the inventory detail subrecord.
var inventoryDetail = inventoryTransfer.getCurrentSublistSubrecord({
sublistId: 'inventory',
fieldId: 'inventorydetail'
});
// You probably should be using dynamic calls on the inventoryDetail sub record
// If you are have a from bin number then you likely need a to bin number:
inventoryDetail.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'binnumber',
value: binId, // a valid bin internal id at the 'from' location
});
inventoryDetail.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'tobinnumber',
value: toBinId, // a valid bin internal id at the 'to' location
});
Another note is that I personally try to use non-dynamic mode for transfer order scripting. The code tends to be much cleaner.