Anyone got experience with a Map/Reduce based on S...
# suitescript
c
Anyone got experience with a Map/Reduce based on SuiteQL? I'm running into a
Invariant check for stage 'INPUT' check failed for 'SELECT [5x] FROM [1x] GROUP BY [1x]
error. The query in itself is running fine (slow nevertheless). I've used the help way to return the suiteql in the input stage, just a different query.
s
Why are you trying to put the table name in quotes? If making a new script, use 2.1, and use string literals. It is much easier to read than concatenated strings
Copy code
// Construct the SuiteQL query string
        var suiteQL =
            `SELECT
                TRANSACTION.tranid AS tranidRAW,
                TRANSACTION.trandate AS trandateRAW,
                BUILTIN.DF(TRANSACTION.postingperiod) AS postingperiodDISPLAY
            FROM
                TRANSACTION
            WHERE TRANSACTION.ID = ?`;
for example
c
This is a copy from the Suitescript help documentation, not my actual query.
s
I've never encountered that error but it seems to not like whatever grouping in your suiteQL (not very helpful)
c
Hmm, snippet failed. But funny thing is, I don't even have a grouping
Image instead
j
don’t put quotes or ${} stuff in SuiteQL
just regular SQL
c
I could try to see if it's working then, although I need to create a dynamic SQL based on custom records data
j
this looks like some strange mashup of freemarker syntax and regular SQL
c
It's working fine in other scripts btw
j
ok, maybe I’m just not familiar with that
${variablename}
syntax outside of freemarker
I recommend logging out the whole sql string that is created there and make sure it looks correct
c
It is working, I logged it and ran it multiple times in Tim's tool. And the actual code is in a library used in other scripts where the same part is working as it should so it feels like a Map/Reduce quirck
j
Could be
Map/Reduce should work fine with SuiteQL in general though, I use them together. Might just be a fun game of stripping down the query to the bare minimum and adding things back in till it breaks.
c
Do you also return the query in itself or gather the results and use that in the return of the input?
j
the latter
c
I've used that as well and that is indeed working. Problem though is that I have more than 5k results and paging didn't work that well but I guess it's the only way due to return the query in itself doesn't seem to work
j
I wrote myself a wrapper module for SuiteQL so I can get more than 5k results 😉
basically I now do
md_query.getFullResults({sql: sql});
instead of
query.runSuiteQL({query: sql}).asMappedResults();
c
Without promises I guess? Trying to use promises let to
Copy code
Search error occurred: Invalid or unsupported search
so that seemed like a no-go as well. Back to the non-promises, cheers