0

I'm starting to understand the Map/Reduce framework more and more for SuiteScript 2.0. However, all the help and SuiteAnswer articles show direct field relationships from the searchResult object.

How do you return a joined field as a Object Value during the map stage?

Example:

{"recordType":"manufacturingoperationtask","id":"1974","values":{"item.workOrder":{"value":"1517","text":"Agent Orange Pale Ale : AOP 1/2"},"enddate":"10/13/2017","formulanumeric":"65"}}

In this SearchResult object, I am trying to return the 1517 item internal id but haven't found a way to get it because the key is "item.workOrder".

Josh Brox
  • 1
  • 1

1 Answers1

1

I suppose if you just want to parse out the JSON string above, then it would be

var data = JSON.parse(result);
var workOrderId = data["item.workOrder"].value;

However, the typical way of accomplishing this through SuiteScript would be to use the Search Result Object's getValue method, along with its join option.

var workOrderId = result.getValue({
    name: "workOrder",
    join: "item"
});

FWIW I've written a whole series of example-driven cookbooks to help you master Searching in SuiteScript.

erictgrubaugh
  • 8,519
  • 1
  • 20
  • 28