This topic contains 9 replies, has 0 voices, and was last updated by starlingMark 7 years, 11 months ago.

  • Author
    Posts
  • #1454

    starlingMark

    I’ve created a script where I am running a search and then formatting the output for the user. This search has two columns that are formula numeric, so I need to use getValue(column) to get the data. To debug I’m just trying to grab a value and spit it out to the execution log as so

    Code:
    var currentResult = salesResults[0];
    log.debug({ title: ‘Customer’, details: currentResult.getValue({column: currentResult.columns[0]}) });
    I’ve tried logging out currentResult and it is correct.

    However, this always generates an error Result.getText: Missing a required argument: name”. I can successfully grab the data if I use the .getValue(name: ‘foo’, summary: ‘group’) but that will only allow me to retrieve the first formula numeric column.

    Anyone had a similar situation – or am I overlooking something simple here?
    This is a cached copy. Click here to see the original post.

  • #1455

    darrenhillconsulting

    starlingMark , care to share more code? Can we see how you setup the search in the first place? Reason being is, in some situations, the searchResult object won’t be fully populated (ie. when being uses in the Map/Reduce script. When you log-out currentResult, what does it look like?

  • #1456

    starlingMark

    darrenhillconsulting Happy to share the rest of the code, but there’s not much more to be shared:

    Code:
    var salesResults = search.load({ id: ‘customsearch_starling_prog_rev_and_targ’ }).run().getRange({ start: 0, end: 1000 });
    var currentResult = salesResults[0];
    log.debug({ title: ‘Customer’, details: currentResult.getValue({column: currentResult.columns[0]}) });

  • #1457

    starlingMark

    Just added a line to log out currentResult and I see the following:

    Code:
    {“values”:{“GROUP(mainname)”:[{“value”:”432″,”text”:”TEST CUSTOMER”}],”GROUP(customerMain.custentity_cust_rev_forec)”:”36386.00″,”SUM(formulacurrency)”:”.00″,”SUM(formulanumeric)”:”31035″}}

  • #1458

    darrenhillconsulting

    Hmmm … ok. I don’t think you want

    currentResult.columns[0] I think you want

    salesResults.columns[0]

  • #1459

    starlingMark

    Per your kind suggestion, I changed the code to:

    Code:
    log.debug({ title: ‘Customer’, details: currentResult.getValue({column: salesResults.colums[0]}) });
    And I received “Cannot read property 0 from undefined”. I tried logging out salesResults.columns and it was empty.

    I then changed the code to this:

    Code:
    var salesResults = search.load({ id: ‘customsearch_starling_prog_rev_and_targ’ }).run();
    var salesColumns = salesResults.columns;
    salesResults = salesResults.getRange({ start: 0, end: 1000 });
    var currentResult = salesResults[0];
    log.debug({ title: ‘Current Result’, details: currentResult });
    log.debug({ title: ‘Customer’, details: currentResult.getValue({column: salesColumns[0]}) });
    This gave me same error as before “Result.getValue missing a required argument: name”.

    Sometimes I miss SS1

  • #1460

    darrenhillconsulting

    Last thing, try doing

    currentResult.getValue(currentResult.columns[0]) (In your original solution) Notice you’re passing the column in directly, rather than a property of an object.

  • #1461

    starlingMark

    Check out the big brain on Darren! That worked!

    It should be noted then that the example provided in the NS API reference here is incorrect.

    For all those who come after us, the proper usage is Result.getValue(column) NOT Result.getValue({ column: column }).

  • #1462

    erictgrubaugh

    Glad you got a working solution.

    As you’ve hit on, there are two versions of `N/search.Result.getValue`. One of which accepts a Column object directly; the other accepts an object, as you were originally trying to use.

    Valid properties for the object passed to getValue are “name”, “join”, and “summary”.

    For reference, see the Help page titled “Result.getValue(options)”

  • #1463

    starlingMark

    Originally posted by erictgrubaugh

    View Post

    For reference, see the Help page titled “Result.getValue(options)”

    That was exactly what I was using as my guide. Per the link in my post above, if you look at the example that is provided it shows it as this:

    Code:
    var value = firstResult.getValue({ colulmn: resultSet.columns[1] }); // get the value of the second column (zero-based index)
    Which is incorrect. Upon closer examination of the text description near the top of the page, it does show that the syntax is Result.getValue(column). However the example is bogus.

You must be logged in to reply to this topic.