I have come across this error while saving some it...
# suitescript
a
I have come across this error while saving some items.
b
assuming you are actually trying to set an item on a sublist
but the error is saying that the item with internal id 5207 is an invalid choice for the field you are trying to set
a
yes trying to set an item on sublist
if(itemInteralId){ salesOrder.selectNewLine({ sublistId: 'item' }); itemInteralIds[itemId] = itemInteralId; salesOrder.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: itemInteralId }); salesOrder.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: itemsData.item[itemData]["qty_ordered"]["#text"] //qty_ordered }); salesOrder.commitLine({ sublistId: 'item' }); } else { ERROR_MESSAGES.push('Item doesnot exist in netsuite:'+ 'Magento product Id:'+itemsData.item[itemData].item_id["#text"]+' Magento product sku:'+itemsData.item[itemData]["sku"]["#text"]); }
is there any issue
b
is salesOrder from N/currentRecord or N/record
a
N/record
if(itemsData.item.length){ for (var itemData in itemsData.item) { var itemId = itemsData.item[itemData].item_id["#text"]; var itemInteralId = searchInItem(itemsData.item[itemData]["sku"]["#text"]); SUCCESS_MESSAGES.push('Item internal Id :'+ itemInteralId); SUCCESS_MESSAGES.push('Quantity Ordered :'+itemsData.item[itemData]["qty_ordered"]["#text"]); if(itemInteralId){ salesOrder.selectNewLine({ sublistId: 'item' }); itemInteralIds[itemId] = itemInteralId; salesOrder.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: itemInteralId }); salesOrder.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: itemsData.item[itemData]["qty_ordered"]["#text"] //qty_ordered }); salesOrder.commitLine({ sublistId: 'item' }); } else { ERROR_MESSAGES.push('Item doesnot exist in netsuite:'+ 'Magento product Id:'+itemsData.item[itemData].item_id["#text"]+' Magento product sku:'+itemsData.item[itemData]["sku"]["#text"]); } } } else{ var itemId = itemsData.item.item_id["#text"]; var itemInteralId = searchInItem(itemsData.item["sku"]["#text"]); SUCCESS_MESSAGES.push('Item internal Id :'+ itemInteralId); if(itemInteralId){ salesOrder.selectNewLine({ sublistId: 'item' }); itemInteralIds[itemId] = itemInteralId; salesOrder.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: itemInteralId }); SUCCESS_MESSAGES.push('Qty Ordered :'+ itemsData.item["qty_ordered"]["#text"]); salesOrder.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: itemsData.item["qty_ordered"]["#text"] //qty_ordered }); salesOrder.commitLine({ sublistId: 'item' }); } else { ERROR_MESSAGES.push('Item doesnot exist in netsuite :' +'Magento product Id:'+itemsData.item.item_id["#text"]+' Magento product sku:'+itemsData.item["sku"]["#text"]); } } } catch(e){ ERROR_MESSAGES.push('Error in Saving Items: '+e); } /*
here is the full code .. The Issue is in the loop
b
create a sales order in the ui using the customer you are trying to use
a
Only the code inside the for loop is throwing error
b
try to set the item you are trying to set in script on the sales order
if its there, something weird is happening
if its not, the item is not a valid choice for your customer
a
ok i shall check
I could not add the item in any sales order . It wasnt showing in the items list
b
as i said, not a valid selection
a
but the item exists in netsuite
b
there are a bunch of things that make an item invalid for selection
common ones are:
inactive items
classification restrictions
item filter on transaction form
a
how can i know that my item is inactive
where is that specified exactly
b
its a field on the item record
a
In the System Information tab ?
b
on standard forms, yes
a
Thank you very much sir ..
Item is inactive thats the issue .. You were right .. Thanks for help