Item search returning incorrect value

I’m currently working on a Suitelet script in SS2.0 and am encountering an issue with returned search values. I’ve seen the same issue before in SSP, assumed it was a bug and simply worked around it – but wouldn’t expect to see the same with a regular Suitescript release.

I have an item saved search set up in the UI, which includes the column “Name”. This works fine and returns our product’s item code.

If I load the same search in SS2.0, result.getValue(‘itemid’) is returning the value from storedisplayname instead.

I tried dumping a JSON.stringify on the search result and the raw search output displays the same issue – and doesn’t contain the item code anywhere.

Is there some quirk to item searches I need to know about?

Beginner Asked on November 29, 2019 in SuiteScript.

can you post your item saved search code? just tried in a demo account and am getting the expected result here.

on December 2, 2019.
Add Comment
4 Answer(s)

I’ve seen occasional quirks in NS displays in the Saved Search UI.

Have you managed to get the data you need? If not, have you tried joining to the Item record to get the field?

Intermediate Answered on December 2, 2019.
Add Comment

Is the value (including the item code) you are expecting inside the field ITEM NAME/NUMBER? Which is basically the “itemid” column. I tried this on my test account and was able to pull what’s inside the said field.  I did not get the Display Name column. My saved search is pretty basic, no formulas or anything. And I used the snippet below.

var mySearch = search.load({
id: 'customsearch67_2'
});
mySearch.run().each(function (result) {
itemName = result.getValue({
name: 'itemid'
});
console.log(itemName);
return true;
});

Is the item code the only thing missing? I have experience where UI Saved Search combines certain data like Item Code + Item Name, but when getting the data through scripting, it will only show one or the other. One suggestion is to use formula, simply put {itemid}, it should display the same thing, and use this formula column in the script.

Hope it helps.

Rookie Answered on December 4, 2019.
Add Comment

I tried copying the above code snippet into a suitelet and found it worked OK. I then realised that the difference was that I’m running mine “Available without login” and testing on a public facing URL (it’s for a data feed integration).

Running my script as administrator, the correct {itemid} values come out. Running it as anything else, I get {storedisplayname} values instead – even using our “superuser” role, which is basically administrator with the mandatory 2FA customization permissions removed. From the deployment screen, I can run the same script and output a CSV with different column values depending on whether I use the UI or external URL links.

It’s obviously a permissions issue, but I presume also an underlying bug somewhere. I can’t believe Netsuite intended it to swap values rather than return an error.

 

Beginner Answered on December 4, 2019.

Glad you were able to sort it out. This definitely sounds like a bug to me as well.

on December 5, 2019.
Add Comment

Team,

Though not entirely related to this, I ran into an issue with a Summary saved search NOT returning the same results in script than in the UI. Turns out the issue was the “Filter By” option. This was set to Order Type, but the transaction search was running on only Journal Entries for specific accounts. Oddly, this resulted in only a few rows not returning data in script tho returning data in the UI.

 

Hope this helps someone in the future!

Beginner Answered on March 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor