Still trying to figure out a solution to get the R...
# suitescript
c
Still trying to figure out a solution to get the Revenue Arrangement Internal ID on a workflow action script that runs on the revenue plan? Anyone have any advice or tips?
b
not familiar with those records
standard approach is to load the revenue plan in the debugger to see what fields are available on it
if you find your revenue arrangment, use that field
if not, do a search
you can do the same thing with logging
c
yea i think the only way i can do it is a search. The plan only holds the element and the element, which has the rev arrangement, isn't a record you can load
the one problem i ran into with a search is the getValue just returned the text from the element instead of the ID
b
which column are you using?
c
Copy code
/**
 * @NApiVersion 2.x
 */

require(['N/search'], function(search) {


    var mySearch = search.create({
        type: search.Type.REVENUE_PLAN,
        columns: ['internalid', 'revenueelement.revenuearrangement'],
        filters: ['internalid', 'is', '745201']
    });

    var myResultSet = mySearch.run();
       

    var resultRange = myResultSet.getRange({
        start: 0,
        end: 50
    })[0];

    log.debug(resultRange)

    var value = resultRange.getValue(myResultSet.columns[1]);

});
This was my test search, but it returns Revenue Arrangement #12345. I am not sure how to get the internal ID though. Is it possible to change searches together and use that value to search the arrangement table?
Also I have no idea if this search will work in a Workflow action script context. I was just testing to see if I can even get the information this way
b
try a text formula that uses '{revenueelement.revenuearrangement.id}'
c
It just returns "Revenue Arrangement #...". Even tho it's a link on the revenue element it doesn't seem to store the ID of it. Is it possible to pull the href value in suitescript?
b
unlikely
c
hmm I really hate that they don't link all these records together in a cleaner way. There must be a way to do it because when you mark a plan on hold, the status on the arrangement changes.
b
might be, but i dont know rev rec stuff well and dont like enabling features i cant turn off in test account
c
yea
thanks for the advice
Netsuite Support coming through!
I needed to use a join against the RevArr
Copy code
var revenueelementSearchObj = search.create({
             type: "revenueelement",
             filters:
             [
                ["internalidnumber","equalto", revElementId] 
             ],
             columns:
             [
                search.createColumn({
                   name: "internalid",
                   join: "revenueArrangement",
                   label: "Internal ID"
                })
             ]
          });
          var searchResultCount = revenueelementSearchObj.runPaged().count;
          log.debug("revenueelementSearchObj result count",searchResultCount);
          var revArrID;
          revenueelementSearchObj.run().each(function(result){
             // .run().each has a limit of 4,000 results
             revArrID = result.getValue({
               name: "internalid",
               join: "revenueArrangement"
             });
             return true;
          });
          
        log.debug("Support - revArrID", revArrID);