This topic contains 2 replies, has 0 voices, and was last updated by MikeBucklaew 7 years, 2 months ago.

  • Author
    Posts
  • #21544 Score: 0

    Auggie
    • Contributions: 0
    • Level 1

    I have a Suitelet that I am using to load an existing transaction saved search. I load the search, add a filter to get results for only one date, run the search, use the forEachResult function with an unnamed function in which I try to get a value from the current row.

    Code:
    function generateReport(request, response){
    //get request parameters
    var reqDateProcessed = request.getParameter('dateProcessed');
    //create filter with date from request
    var filters = new Array();
    filters[0] = new nlobjSearchFilter('trandate', null, 'on', reqDateProcessed);
    //load saved search
    var searchResults = nlapiLoadSearch('transaction','customsearch_mycustomsearch');
    //add filter
    searchResults.addFilters(filters);
    //run saved search
    var resultSet = searchResults.runSearch();
    //iterate through result set
    resultSet.forEachResult(function (eachResult){
    var x = eachResult.getValue('custbody_customfieldname');
    return true;
    });
    }
    In the debugger for eachResult it shows that the id=null, recordType=null, columns = {array} length=16 and it shows the correct set of values for each row as it iterates through the search. No matter what value I try to get from eachResult it shows up as undefined. I've tried the custom fields as well as the standard fields like 'trandate'.

    I can see the values in the debugger. What am I missing to be able to get those values out of eachResult?
    This is a cached copy. Click here to see the original post.

  • #21545 Score: 0

    MikeBucklaew
    • Contributions: 0
    • Level 1

    Where are you trying to use the data? You're creating the variable x within the function and it will be out of scope if you try to use it elsewhere.


    Auggie replied on 06/29/2017, 09:34 AM: Yes, this is just an attempt at getting a value. I was doing an nlapiLogExecution and trying to log the value within the function. Now I’m just stopping it there in the debugger to see if I get a value.

  • #21546 Score: 0

    MikeBucklaew
    • Contributions: 0
    • Level 1

    Does your saved search have any summary results or joins? If so you have to add them to getValue. For instance

    Code:
    eachResult.getValue('custbody_customfieldname', null, 'sum');


    Auggie replied on 06/29/2017, 09:49 AM: Yes! That was it. It was a group result. Thank you!

You must be logged in to reply to this topic.