This topic contains 3 replies, has 0 voices, and was last updated by karenn 7 years, 1 month ago.

  • Author
    Posts
  • #18230

    karenn

    Hi all,

    I am stumped. I have a Suitelet that runs a saved search, we process the results and then display info. IT has been working for months but suddenly it is producing an error.

    Here is part of the code

    salesSearch.run().each(function(result) {

    log.debug({title: ‘result’, details: result});

    var moyr = result.getValue({name: ‘trandate’, summary: ‘GROUP’});

    var qty = result.getValue({name: ‘quantity’, summary: ‘SUM’});

    var amt = result.getValue({name: ‘amount’, summary: ‘SUM’});

    var strAmt = format.format({ value: amt, type: format.Type.CURRENCY });

    var cost = result.getValue({name: ‘costestimate’, summary: ‘SUM’});

    var strCost = format.format({ value: cost, type: format.Type.CURRENCY });

    var profit = result.getValue({name: ‘estgrossprofit’, summary: ‘SUM’});

    var strProfit = format.format({ value: profit, type: format.Type.CURRENCY });

    var avgcost = result.getValue({name: ‘costestimaterate’, summary: ‘AVG’});

    var strAvgCost = format.format({ value: avgcost, type: format.Type.CURRENCY });

    var PMPcnt = ( parseFloat(profit) / parseFloat(amt) ) * 100;

    var strPMPcnt = format.format({ value: PMPcnt.toFixed(2), type: format.Type.PERCENT });

    log.debug({title: ‘moyr’, details: moyr});

    log.debug({title: ‘qty’, details: qty});

    if (moyr.substring(0,4) != prevmoyr.substring(0,4) && prevmoyr != ”)

    {

    it is erroring on this last if statement

    org.mozilla.javascript.EcmaError: TypeError: Cannot call method “substring” of null (/SuiteScripts/PE Scripts 2.0/pe2_sl_itesmsaleshistory.js#122)

    the debug output shows there is a value for trandate in the search but the var moyr is blank and I have no idea why

    Debug
    moyr

    result

    {“values”:{“GROUP(trandate)”:”2017-10″,”SUM(quantity)”:”182″,”SUM(amount)”:”4496.72″, “SUM(costestimate)”:”2169.44″,”SUM(estgrossprofit) “:”2327.28″,”AVG(costestimaterate)”:”11.92″,”AVG(r ate)”:”24.91″}}

    Debug
    {“details”:{“name”:”rate”,”summary”:”AVG”,”label”: “Avg Price”,”type”:”currency2″,”function”:”roundT

    Debug
    {“details”:{“name”:”costestimaterate”,”summary”:”A VG”,”label”:”Avg Cost”,”type”:”currency”,”sortdir

    Debug
    {“details”:{“name”:”estgrossprofit”,”summary”:”SUM “,”label”:”Profit $”,”type”:”currency”,”sortdir”:

    Debug
    {“details”:{“name”:”costestimate”,”summary”:”SUM”, “label”:”Total Cost”,”type”:”currency”,”sortdir”:

    Debug
    {“details”:{“name”:”amount”,”summary”:”SUM”,”label “:”Sales Dollars”,”type”:”currency”,”sortdir”:”NO

    Debug
    {“details”:{“name”:”quantity”,”summary”:”SUM”,”lab el”:”Qty Sold”,”type”:”float”,”sortdir”:”NONE”}}

    Debug
    {“details”:{“name”:”trandate”,”summary”:”GROUP”,”l abel”:”Yr-Mo”,”type”:”date”,”function”:”month”,”s
    This is a cached copy. Click here to see the original post.

  • #18231

    karenn

    Hi All,

    one additional note. The date column in the search also as a Month function attached to it in addition to the grouping. If I take this off it runs but of course does not give me what I want. Why is the Month function causing the getValue to be null?

    Thanks!

  • #18232

    MChammaTX

    I think starlingMark already answered this issue a few weeks ago in the following post:

    https://usergroup.netsuite.com/users…tation-has-not

  • #18233

    karenn

    Thanks! Had a feeling it was something like that. They REALLY need to update documentation when they make changes like this. When they don;t update hard to know what the parameter is supposed to be func, function or something else.

    Thanks to both of you!!!

You must be logged in to reply to this topic.