var item = record.load({ typ...
# suitescript
a
var item = record.load({ type: record.Type.INVENTORY_ITEM, id: 2712 }); log.debug('Item details ', item); var inv=item.getSubrecord({ fieldId: 'inventorydetail' }); var split=JSON.stringify(inv).split(","); for(var s=0;s<split.length;s++) { log.debug('inventory ', split[s]); } Error {"type":"error.SuiteScriptError","name":"FIELD_1_IS_NOT_A_SUBRECORD_FIELD","message":"Field inventory is not a subrecord field.","stack":["anonymous(N/serverRecordService)","takeAction(/SuiteScripts/Webhive/ma_inventory_transfer.js:54)"],"cause":{"type":"internal error","code":"FIELD_1_IS_NOT_A_SUBRECORD_FIELD","details":"Field inventory is not a subrecord field.","userEvent":"beforesubmit","stackTrace":["anonymous(N/serverRecordService)","takeAction(/SuiteScripts/Webhive/ma_inventory_transfer.js:54)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false} ************************************************* I want to get the quantity available for the specific inventoryitem for a specific location. How can i do that using suit script ! I tried but encountered the error mentioned above,
b
do you know the difference between a sublist and a subrecord?
a
I will have a look at it
How do i know difference between sublist and subrecord ? Record Browser ?
b
usually its a simple concept. Sublists are rows of data, subrecords are records that are part of another record
a
I am trying to fetch quantity available for the specific location.. What should i do in this case ? var item = record.load({ type: record.Type.INVENTORY_ITEM, id: 2712 }); log.debug('Item details ', item); var inv=item.getSublist({ sublistId: 'inventoryassignment' }); Tried this but didn't work
b
have you ever worked with sublists before
a
yes item sublist on sales order
b
the sublist is not very different
you get its id, and then its fields and use the getSublistValue method
getSublist is for getting metadata about the sublist
and there is no inventoryassignment sublist on an inventory item
a
where can i find the id of this sublist in record browser
b
item is for generic item searches
you want inventory part
that said, doing an item search is generally how i would get inventory quantity related information
a
ok understood so i should run a saved search and then get details instead of directly getting value after loading a record that i am doing right now
b
either way works, if you will be getting information for many items, do a search, if you are getting information for 1 item, do whatever you like best
for me, that generally means search since its easier to do it 1 way rather than 1 for each case
if i was modifying the item record, i may consider doing the record load
👍 1
a
Understood .. Thanks for help