assuming there is only one serial number (12345) -...
# suitescript
m
assuming there is only one serial number (12345) - how do i select this in code? currently (to test) i hard coded the serial number to see if I can create the line and that seems fine, but not sure how to select the value from the drop down
b
generally you have 3 options for this sort of thing: a) Record.setCurrentSublistText b) Record.setCurrentSublistValue with an internal id from Field.getSelectOptions c) Record.setCurrentSublistValue with an internal id from an item search
m
i think i need b) i will try this, thanks for the suggestion
i tried this but i get Cannot find function getSelectOptions in object:
var opts = inventoryDetailSubrecord.getCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'issueinventorynumber', }).getSelectOptions(); inventoryDetailSubrecord.setCurrentSublistText({ sublistId: 'inventoryassignment', fieldId: 'issueinventorynumber', value: opts[0].value });
not sure if i can use the getSelectOption in this manner
b
that code shouldn't work, getCurrentSublistValue doesn't return a Field, setCurrentSublistText doesn't work with the value from a select option
im not sure what the context of your code is, but getSelectOption is a method of a Field and generally only works on dynamic mode records
m
how should i use this for the serial/lot number drop down inside the inventory details subrecord?
b
the dropdown is a select field
there are 2 ways to set select fields, with the text value using a variant of setText, and with the internal id number with a vairant of setValue
the first option I gave you requires you to exactly match whatever text the select field uses
its honestly hit or miss since the text isn't always what you expect
the second option takes advantage that NetSuite provides a list of valid select options which is accessible from the metadata stored in a Field object
the select options includes both the text value and the internal id value, however you might as well use the internal id if you reached this point
the third option is for when you just can't get the select options, so you search for valid values yourself
i generally like option 2
which requires you to use Record.getSublistField to get the Field and then Field.getSelectOptions which gets the select options and finally to use the value key of one of the returned select options to use in the select field
m
Thanks for the info- will try again in a bit.
thanks, went for option 2 and that worked