How do I pull formula results out of a search? He...
# suitescript
m
How do I pull formula results out of a search? Here's the result of getAllValues and the columns: 10:26 AM {"GROUP(account.name)":"570912 Overhead Recovery - XADA","SUM(formulacurrency)":"145155.00","SUM(formulacurrency)_1":"135478.00","SUM(formulacurrency)_2":"9677.00"} VM3768 Search Help:101 [{"name":"name","join":"account","summary":"GROUP","label":"Account","type":"text","function":null,"formula":null,"sortdir":"ASC","whenorderedby":null,"whenorderedbyjoin":null},{"name":"formulacurrency","join":null,"summary":"SUM","label":"1","type":"currency","function":null,"formula":"nvl({debitamount},0)","sortdir":"NONE","whenorderedby":null,"whenorderedbyjoin":null},{"name":"formulacurrency","join":null,"summary":"SUM","label":"2","type":"currency","function":null,"formula":"nvl({creditamount},0)","sortdir":"NONE","whenorderedby":null,"whenorderedbyjoin":null},{"name":"formulacurrency","join":null,"summary":"SUM","label":"3","type":"currency","function":null,"formula":"nvl({debitamount},0)-nvl({creditamount},0)","sortdir":"NONE","whenorderedby":null,"whenorderedbyjoin":null}]
s
You have to include the same column definition: result. getValue(columnDefinition)
m
Thanks, got it working using getValue(column[0]), etc., but there's another way to do it using formula_1, formula_2 etc. I can't remember how to do the second way, do you?
s
ah, yes.. you can just name the formula property formula1
I’d rather keep distinct definitions and refer to them via their index..
I usually create them in an object so I can refer to them by name.. {funkySum: search.createColumn(), funkySum2: search.createColumn()}
e
Having trouble generating this as a PDF, so you'll have to parse through the markdown, but here's the sample chapter from my Advanced Search Cookbook (https://stoic.software/cookbooks/) which covers working with multiple formulae
Line 133 starts the Multiple Formula section
m
Thanks. This is awesome!