Hello all, I've created two custom transaction bod...
# suitescript
a
Hello all, I've created two custom transaction body fields on a Sales Order, "Contact Email:" "Contact Phone:" We have another custom field called "Requested By:" Using two saved searches, I'm pulling the email and the phone number to those two fields automatically dependent on which contact is chosen from the record in the Requested by field. This works perfectly and I'm able to print it to an Advanced PDF/HTML form no problem. However, we have a separate "Work Order" form that we're actually creating using a script I've printed any field I wanted so far, using something like this: var fields = ['example'] var columns = nlapiLookupField('salesorder', stSOID, fields); var stExample = colums.custbody_example after this, I'm able to push them with xml without issue. For some reason though, these two fields being populated via Saved Search don't seem to function the same way. Is this just something that NetSuite isn't capable of, or is there a different way to grab/print these fields? Please let me know if you need anymore information or have any questions. I'd really like to figure out what's going on here and appreciate any input. Thank you!
j
I could be wrong, but I don’t think nlapiLookupField works on non-stored values.
m
It won’t work on a non-stored field that is sourced via a search for sure. Your script would need to have logic that gets those values via the search and plugs them into your XML.
a
Thanks Matt. Could you elaborate on what that logic might look like?
m
Copy code
var contactEmail = nlapiLoadSearch(mySearchId).runSearch().getResults(0,1)[0].getValue(theColumnNameFromTheSearch);
Might look something like that. My SuiteScript 1.0 is rusty and I’m doing this from memory, so that might not be exactly right.
c
Do you even need a saved search to do this? If the custom Record referenced by the field "Requested By" has the info, you can do a regular source or use a text-field and use the default value on the field setup to enter it yourself with the {record.value} notation.
You'd still have to look up the Sales Order info from the Work Order as you can't source a source but it removed the saved search field.
m
That’s a good point too. Several cat-skinning techniques could be valid.
🍺 1
a
"Do you even need a saved search to do this? If the custom Record referenced by the field "Requested By" has the info, you can do a regular source or use a text-field and use the default value on the field setup to enter it yourself with the {record.value} notation."
You mean in the script itself, just use a text field and print the default value? Sorry I'm a bit of a rookie
@creece