Hello everyone, would the following code be a good...
# suitescript
k
Hello everyone, would the following code be a good foundational for getItemFulfillments based on a sales order id?
Copy code
function getItemFulfillments(salesOrderID) {

      // Call itemfulfillments based on sales order id
      var itemfulfillmentSearchObj = search.create({
        type: "itemfulfillment",
        filters: [
          ["type", "anyof", "ItemShip"],
          "AND",
          ["appliedtotransaction.type", "anyof", "SalesOrd"],
          "AND",
          ["appliedtotransaction.internalid", "anyof", "175216"]
        ],
        columns: [
          search.createColumn({
            name: "internalid",
            summary: "GROUP",
          })
        ]
      });
      var searchResultCount = itemfulfillmentSearchObj.runPaged().count;
      log.debug("itemfulfillmentSearchObj result count", searchResultCount);
      itemfulfillmentSearchObj.run().each(function (result) {
        var ifid = result.getValue({
          name: 'id'
        });
        log.debug('ifid', ifid); // debugs ifid twice with blank details
        return true;
      });

    }
b
you should be able to try it
i wouldnt expect it to work, but you should have an easier time telling if the code should work over us
k
The code is able to iterate over the saved search, but I'm not sure if I'm using the proper method to grab the internal id.
c
result.getValue({name: 'internalid', summary: search.Summary.GROUP}) Needs to match the column you're creating. You can sometimes use searchResult.id to get the record ID as well.
k
That work! Thank you for the help!