This topic contains 9 replies, has 0 voices, and was last updated by starlingMark 7 years, 11 months ago.
-
AuthorPosts
-
November 29, 2016 at 5:38 am #1454
starlingMarkI’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. -
November 29, 2016 at 6:34 am #1455
darrenhillconsultingstarlingMark , 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?
-
November 29, 2016 at 6:39 am #1456
starlingMarkdarrenhillconsulting 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]}) }); -
November 29, 2016 at 6:41 am #1457
starlingMarkJust 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″}} -
November 29, 2016 at 6:46 am #1458
darrenhillconsultingHmmm … ok. I don’t think you want
currentResult.columns[0] I think you want
salesResults.columns[0]
-
November 29, 2016 at 6:57 am #1459
starlingMarkPer 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
-
November 29, 2016 at 7:05 am #1460
darrenhillconsultingLast 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.
-
November 29, 2016 at 7:40 am #1461
starlingMarkCheck 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 }).
-
November 29, 2016 at 8:30 am #1462
erictgrubaughGlad 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)”
-
November 29, 2016 at 8:36 am #1463
starlingMarkOriginally 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. -
AuthorPosts
You must be logged in to reply to this topic.