has anyone had experience with findSublistLineWith...
# suitescript
m
has anyone had experience with findSublistLineWithValue not working in a restlet on a dynamic record? Specifically working with customer/vendor tax registration sublist in suitetax
Works fine when using suitescript in console, returns -1 when working in restlet
ended up swapping to a .find loop (straight javascript) which works as well (though given how messy it is would prefer to figure out the findsublist issue)
e
Where does the
Record
instance come from in the Restlet?
m
it's a dynamic record loaded like...
rec = record.load({ type: 'customer', id: whatever, isDynamic: true })
Copy code
rec.findSublistLineWithValue('taxregistration', 'nexuscountry', 'US')
is an example that does not work in the restlet (2.1) but does work via suitescript in console. Tested with hard coded 'US' though obviously the eventual goal is a variable (
row['country']
)
e
Have you compared the values stored in
nexuscountry
between the Restlet and console? Maybe it's a different value on the server side
m
sorry for the delay, yes we did log the values for nexuscountry in the restlet and they returned 'US', 'DE', etc. as expected
cleaned up some other comments, just to simplify this here is the info in rails debugger (where it's not working)-
Copy code
rec.toJSON().sublists.taxregistration['line 1']
=> {address: null, id: "1673", nexus: "3", nexus_display: "Germany", nexuscountry: "DE", …}
existingLineNumber = rec.findSublistLineWithValue('taxregistration', 'nexus', 'DE')
=> -1
rec.toJSON().sublists.taxregistration['line 1']['nexuscountry'] == 'DE'
=> true
rec.id
=> 5659
and here in console:
Copy code
rec = record.load({ type: 'customer', id: 5659, isDynamic: true })
=> DynamicRecord {getMacros: ƒ, getMacro: ƒ, executeMacro: ƒ, …}
rec.findSublistLineWithValue('taxregistration', 'nexuscountry', 'DE')
=> 0
rec.toJSON().sublists.taxregistration['line 0']['nexuscountry']
=> {value: undefined, legacyStringValue: 'DE'}
not sure if it's notable that the line number is 1 in rails debugger and 0 in console