I am running a search in suitescript, but some of ...
# ask-stanley-ai
j
I am running a search in suitescript, but some of the columns such as accounting period are being returned as internal IDs instead of their display values. How can I return the display values?
c
AI generated answer (using internal Slack threads):
In SuiteScript, when you are running a search and some of the columns such as accounting period are being returned as internal IDs instead of their display values, you can use the
getText
method to get the display value. For columns representing select fields,
Result.getValue
returns the internal id of the select option, while
Result.getText
returns the text of the select option. Here is an example of how you can use these methods:
Copy code
javascript
var searchResult = search.create({
   type: "transaction",
   filters:
   [
      ["type","anyof","SalesOrd"], 
      "AND", 
      ["mainline","is","T"], 
      "AND", 
      ["status","anyof","SalesOrd:B"], 
      "AND", 
      ["custbody_my_custom_field","noneof","@NONE@"]
   ],
   columns:
   [
      search.createColumn({name: "tranid", label: "Document Number"}),
      search.createColumn({name: "custbody_my_custom_field", label: "My Custom Field"})
   ]
}).run().getRange(0,1);

for (var i = 0; i < searchResult.length; i++) {
   var record = searchResult[i];
   var customFieldValue = record.getText({name: 'custbody_my_custom_field'});
   log.debug('Custom Field Display Value', customFieldValue);
}
In this example,
getText
is used to get the display value of the custom field
custbody_my_custom_field
. ****** 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.82695514
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.8258968
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824634373
Please provide your feedback on this answer.