Can we pass a variable of the record type in a rec...
# suitescript
m
Can we pass a variable of the record type in a record.load? (record.Type.myVar)
s
dont understand the question, record.Type.SOMETHING is a string enumeration already there
m
I need to load the item record in a loop. I am unsure of the record type of each item.
s
Sounds like a bad design to load a record in a loop. Would probably make more sense to put all the id's in an array, and create a search for all the properties you want from them. If you do need to load them, typically there is a column that has the item type on most sublists taht use item natively
m
I do not disagree with you there.
b
dot notation is inappropriate for variables
d
I wouldn’t use the dot notation with a variable but set the variable to the whole record type name.
m
Probably a good idea, Danny, but I just went back and rewrote it all a bit more properly so that I did not need to deal with the item types at all. Thanks all.
d
Glad you were able to get it working. How did you rework it to not use the record type on the load operation? I thought it was required.
m
Instead of dealing with looping of items to grab item data, I threw the info needed into a unstored custcol and dealt with it that way.
👍 1
Quicker and obviously more efficient
r
Obviously it is a bad design to load record in a loop. But I still want to answer @mightyd3 questions. If you're not sure which item type you get then you should maps all possible items type in object like this var RECORD_TYPE = {                 "serviceitem":record.Type.SERVICE_ITEM,                 "inventoryitem":record.Type.INVENTORY_ITEM,                 "noninventoryitem":record.Type.NON_INVENTORY_ITEM             } And access these types from this object in loop like record.load({type: RECORD_TYPE[itemRecType],id:itemId})
👍 2
r
@Gayatri Jaiswal