searchResult.getValue({name: 'custitem_last_purcha...
# suitescript
c
searchResult.getValue({name: 'custitem_last_purchase_rate', join: 'item'})
☝️ 2
b
Cannot find function getValue in object [object Object].
e
I assume you have done the search in one stage and are retrieving the result in another
which means the result has been stringified, and it will no longer have its
getValue
and other methods
b
correct, search is done in getInputData
e
Recommend deserializing the result and logging that out to the log to see its structure
b
that is what I thought but was suggested I try
e
I believe it's something like
result.joinname_fieldname
, but I can't recall exactly
or perhaps
result.values.joinname_fieldname
either way, I'd log it out to make sure
b
I tried logging it but I got [object Object] I did: var results = JSON.parse(context.value); and then logged results.values
e
Is this in
map
?
b
yes
e
What does your log statement look like?
b
log.debug({ title: 'results', details: results.values });
e
Odd; looks right to me
wouldn't expect to see
object Object
s
it just dawned on me that I never use that form for
log.debug
. I've stuck with the log.debug(title, details) scheme
e
I've never used the non-object forms since switching to 2.0 ¯\_(ツ)_/¯
b
Log context.value without parsing it
b
I'll give that a try
Thanks @battk that helped. {"recordType":"salesorder","id":"1533485","values":{"transactionname":"Sales Order #539673","item":{"value":"11902","text":"1004450"},"quantity":"3","type.item":{"value":"Assembly","text":"Assembly/Bill of Materials"},"custitem_last_purchase_rate.item":".90"}}
results.values.field.join looks like
Well that didn't work Cannot read property \\\"item\\\" from undefined\
j
if you look carefully at the structure of the object you logged you'll see that the property name actually contains a
.
so you need to access it like this
Copy code
var rate = results.values["custitem_last_purchase_rate.item"];
b
ok, thanks!