How can I use the "params" parameter of the runSui...
# ask-stanley-ai
g
How can I use the "params" parameter of the runSuiteQL method with multiple parameters? According to the documentation on NetSuite.com, it appears that the type of value for this parameter has to be an Array of string, number, boolean type values. How can I insert multiple placeholders in my SQL statement and ensure they are replaced with the correct value from array in "params"?
c
AI generated answer (using internal Slack threads):
To use the "params" parameter of the runSuiteQL method with multiple parameters, you need to pass an array of values that correspond to the placeholders in your SQL query. The placeholders are represented by the
?
symbol in your SQL statement. The order of the elements in the params array should match the order of appearance of the
?
in the query. Here is an example:
Copy code
javascript
query.runSuiteQL({
  query: 'SELECT * FROM transaction WHERE statusref = ? AND entity = ?',
  params: [ 'A', 123 ]
});
In this example, 'A' replaces the first
?
and 123 replaces the second
?
in the SQL query. If you are using an "IN" clause in your SQL statement and you want to pass an array of values, you can use the
join
method to create a string of values separated by commas. Here is an example:
Copy code
javascript
var items = ['item1', 'item2', 'item3'];
var sql = `SELECT * FROM transaction WHERE item.ID IN ('${items.join("', '")}')`;
In this example, the
join
method is used to create a string of item IDs separated by commas and enclosed in single quotes, which is then inserted into the SQL query. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864189327
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835841417
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823447526
Please provide your feedback on this answer.
Thank you for your feedback