The below JSON is what I get when logging out each...
# suitescript
j
The below JSON is what I get when logging out each result of a loaded saved search. The below is me trying to get '5553012'. Can anyone help with the syntax to get a summary formula out of a result? Also if there is something special I need to do to find that second formula?
s
Are you trying in get in M/R script?
j
No, this is a search in a Suitelet.
r
var value = values[“SUM(formulanumberic)“];
you’re dealing with a JSON object there
j
It doesn't handle like JSON object. I get and error if I try to return result.values["SUM(formulanumeric)"]
says "values" is undefined
s
You can use summary parameter in your result!
r
What is the top level value
?
if its result
try result[“values”][“SUM(formulanumeric)“]
s
result[i].getValue({name: "field",summary: "SUM",sort: search.Sort.DESC,label: "Amount Remaining"}) this is something I used to do
If you still want to work on JSON I would suggest you can try to Parse the value and then pull it
j
Thanks @samyt, result.getValue({ name: 'formulanumeric', summary: search.Summary.SUM }); works.
Now how do I get the second formula numeric?
nvm, I'll just make the second a formulacurrency
s
{ name: "formulanumeric", formula: "your formula", label: "Formula (Numeric)" }
j
@samyt, yeah that's how I'd do it if I created the search in the script. This one I want non-developers to maintain so I'm passing saved searches in as parameters, so I don't know how the labeling works... hmm idea maybe I'll load and log out the saved search and see if that gives hints.
s
Or else you can use a delimiter and perform both formula numeric field functionality in one field
For eg :formula(numeric) "553012 &* 90343". You can use get the value using result.getValue() and split using (&*)
j
Nice. I'll keep that in mind as that's a nice workaround. Fo r this script I think just using formulacurrency will be easiest since it's only the two numbers I need.
👍 1
r
You can also get the all the columns then loop thru the columns and get the value using results.getValue(column[index])
👍 1