John
John

Reputation: 67

SuiteScript getting value from a saved search

I'm having an issue pulling the value of a column in SuiteScript v1.0. The search is looking at Cash Sales and is producing the results I want in the UI, but I am unable to get the value of one column in SuiteScript. I suspect it is because either the value comes from the 'Created From' doc, or because it is a drop down list. Any help would be greatly appreciated.

The search looks at Cash Sales where the Dept/Sales Channel (NS id department) doesn't match the Dept/Sales Channel of the Sales Order. The results are:

  1. Type
  2. Document Number
  3. Created From : Dept/Sales Channel

In the UI, it is doing exactly what I hoped. However, when I loop thru the results in my v1.0 SuiteScript, I'm getting a null value for Dept/Sales Channel:

results.forEachResult(function(res){
        var id = res.getId();
        var docid = res.getValue('tranid');
        var dept = res.getValue('channel');
        nlapiLogExecution('DEBUG', 'Found result - '+docid+' ('+id+') - '+dept+'.');

docid and id are correct, but dept ends up being null. I've tried 'channel', 'deptartment' and column[3].value with no luck. What am I doing wrong?

Upvotes: 0

Views: 2208

Answers (1)

Rusty Shackles
Rusty Shackles

Reputation: 2840

Based on how you formatted this: "Created From : Dept/Sales Channel", I assume it is a joined column.

If it is, you need to do it this way:

var dept = res.getValue('department', "createdfrom");

Upvotes: 1

Related Questions