- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 04:52 AM - edited 11-29-2023 04:55 AM
Hello Experts,
I have created a scheduled job to trigger an integration. Where I am storing auc numbers in an array for all the request. I need to pass this AUC number in query parameter. What is the syntax for this?
Piece of code from Scheduled job:
var auc = [];
var pn = [];
//gs.info('test by shantanu 1.1');
var grAuc = new GlideRecord("capp_capital_project");
grAuc.addEncodedQuery('phase=execution^number=CAP0001188');
grAuc.query();
//gs.info("Test by shantanu1" + grAuc.getRowCount());
while (grAuc.next()) {
// gs.info("shantanu1 " + grAuc.u_auc.u_number);
pn.push(grAuc.number);
auc.push(grAuc.u_auc.u_number);
}
JSON content for query:
{
"ReParams": {
"Asset_Number": $[] // what goes inside if I want to pass an AUC Number from an array?
}
}
Thanks,
Shantanu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 06:01 AM
Then in the Rest message content use the following content.
{
"ReParams": {
"Asset_Number": ${auc_num}
}
}
Then save the form and click Auto generate variables related link so that it will generate a variable as shown below.
Then in your scheduled job you can use the following sample script.
//Iterate through AUC array for each request
for(key in auc){
try {
var r = new sn_ws.RESTMessageV2('YOUR REST Message Name', 'REST Message Method Name');
//Set the auc_number in the content using the below line
r.setStringParameterNoEscape('auc_num', auc[key]);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch(ex) {
var message = ex.message;
}
}
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 05:39 AM
Hi @Shantanu K
Are you trying to pass all the numbers in single request or only one for each request.
And are you using any Outbound REST Message for this integration?
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 05:43 AM - edited 11-29-2023 05:44 AM
Hi @AnveshKumar M ,
I am trying to send only 1 number at a time.
Yes I am using Outbound REST Message for this integration.
Thanks,
Shantanu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 06:01 AM
Then in the Rest message content use the following content.
{
"ReParams": {
"Asset_Number": ${auc_num}
}
}
Then save the form and click Auto generate variables related link so that it will generate a variable as shown below.
Then in your scheduled job you can use the following sample script.
//Iterate through AUC array for each request
for(key in auc){
try {
var r = new sn_ws.RESTMessageV2('YOUR REST Message Name', 'REST Message Method Name');
//Set the auc_number in the content using the below line
r.setStringParameterNoEscape('auc_num', auc[key]);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch(ex) {
var message = ex.message;
}
}
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh