When I use SuiteQL in a suitescript I put the quer...
# suiteql
e
When I use SuiteQL in a suitescript I put the query in a string and it gets so messy to edit later. Is there a better way? Like storing the query in a store_procedure and calling it?
c
Depends on your use case. I setup a custom record type to store queries that I use for scheduled scripts and whatnot. But if youre running it in say, a user event script, there will be a performance hit to read the record each time before running the query.
e
I run it fron a scheduled script or restlet
r
load sql from formatted txt file from filecabinet. lock down the folder so people cant change it
👍 1
Copy code
var mySQLQuery1= file.load({id: idOfQeury1file}).getContents();
e
I see that 2.1 scripts let med use
backtick
` That is much better than 2.x 🙂
👍 1
m
yes, the backtick is much cleaner in 2.1 and inputing params is easier too
Copy code
const sql = `
SELECT
    employee.lastname,
    employee.email,
FROM
    employee
WHERE
    employee.id IN (${someIdVariable})
`
👍 1