Reputation: 33
On a custom record creation i am calling a map reduce script that in creating a negative inventory adjustment. The script is called on after submit. I am using following code to populate the inventory detail subrecords
for (var n = 0; n < cp_lotsearch.length; n++) {
if (cree_onhand > 0) {
var cp_lotid = cp_lotsearch[n].getValue({name: 'internalid'});
var cp_parentcasenum = cp_lotsearch[n].getValue({name: 'custrecord_nsts_ia_lot'});
var itemsearch = search.create({
type: 'item',
filters: ['inventorynumber.inventorynumber', 'is', cp_parentcasenum],
columns: [search.createColumn({name: "quantityonhand", join: "inventorynumber"})]
}).run().getRange({
start: 0,
end: 1000
});
var qtyonhand = itemsearch[0].getValue({name: 'quantityonhand', join: 'inventorynumber'});
var remain_qtyonhand = Number(qtyonhand) - Number(cree_onhand);
if (remain_qtyonhand >= 0) {
var reduceqty = 0 - Number(cree_onhand);
} else {
var reduceqty = 0 - Number(qtyonhand);
}
log.debug("reduceqty", reduceqty);
subrecord.insertLine({sublistId: 'inventoryassignment',line: n});
subrecord.setSublistText({ sublistId: 'inventoryassignment',fieldId: 'issueinventorynumber',line: n,text: cp_parentcasenum});
subrecord.setSublistValue({sublistId: 'inventoryassignment',fieldId: 'binnumber', line: n, value: cree_bin});
subrecord.setSublistValue({sublistId: 'inventoryassignment',fieldId: 'quantity',line: n,value: reduceqty});
log.debug("reduceqty added to inventory detail", reduceqty);
cree_onhand = Number(cree_onhand) + Number(reduceqty);
}
}
var invadjid = parentcase_inv_Adj.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
When i try to run this code i am getting following error:
"type":"error.SuiteScriptError","name":"USER_ERROR","message":"You still need to reconfigure the inventory detail record after changing the quantity."
Same code is running perfect in sandbox account but in production it is throwing error
Can anyone help me to solve this error?
I Got one solution in suite answer that i already tried but it is not working here is link to it: https://netsuite.custhelp.com/app/answers/detail/a_id/80790/kw/reconfigure%20error
Upvotes: 1
Views: 2035
Reputation: 13
I've come across this well after it will have been helpful to you, but maybe someone else like me can benefit!
It turned out that, when the Inventory Status feature is enabled, NetSuite creates a line in the Inventory Detail 'inventoryassignment' sublist automatically (as can be seen in the UI). That line is also available when scripting, so you don't need to use insertLine(), only setSublistValue(..., line: 0) and you should be good.
Source was here (quoted from SuiteAnswer 81448): https://community.oracle.com/netsuite/english/discussion/4498970/suitescript-you-still-need-to-reconfigure-the-inventory-detail-record-after-changing-the-quantity
Upvotes: 0
Reputation: 411
I've discovered this error can be triggered server-side if :
However, if the same is attempted client-side, the error becomes "The total inventory detail quantity must be XX" (XX being the quantity set in "adjustqtyby" on the inventory adjustment line).
Upvotes: 0