what is the correct way of fetching formula custom...
# ask-stanley-ai
i
what is the correct way of fetching formula custom fields similar to how Stripe does with
custbody_stripe_invoice_payment_link
<https://app.suitesync.io/payments/test/{type}/{id}>
suitescript 1
nlapiLookupField
doesn't return the value with the flags populated, SOAP Basic Search does it wrong when multiple objects are returned in the same search, SOAP Advanced Search doesn't return it either, and SuiteQl doesn't return non-stored custom fields
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that fetching formula custom fields in NetSuite can be a bit tricky. The
nlapiLookupField
function in SuiteScript 1.0 does not work on non-stored values, especially those sourced via a search. One suggested workaround is to use a saved search to get the values and then plug them into your XML. Here's a sample code snippet provided in the conversation:
Copy code
javascript
var contactEmail = nlapiLoadSearch(mySearchId).runSearch().getResults(0,1)[0].getValue(theColumnNameFromTheSearch);
Another suggestion is to create a new custom field that uses a formula on another custom field and convert it into a text value. The formula should simply be a template expression with the script id of your original field inside. Then, you can fetch this new field instead. In SOAP API, it seems there's no direct way to fetch the value of the custom field inside a saved search similar to UI. The expectation is to do another search or use
getSelectValue
. For getting a list of custom fields or looking up an individual custom field record using SuiteScript, you can use SuiteQL to query for a list of all custom fields with
select * from customfield
. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849426389
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844665527
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836975157
Please provide your feedback on this answer.