- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 04:43 AM - edited 01-30-2024 04:45 AM
Hello,
I have created a rest message and the Preview REST Message script usage looks like this -
try {
var r = new sn_ws.RESTMessageV2('x_775122_enviro_tr.Get Tree Name', 'Post');
r.setStringParameterNoEscape('clientName', 'client2');
r.setStringParameterNoEscape('jobId', 'job2');
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthenticationProfile(authentication type, profile name);
//set a MID server name if one wants to run the message on MID
//r.setMIDServer('MY_MID_SERVER');
//if the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.message;
}
I want to add this script as a UI Action to create a button for my form. When i add this script directly, it works fine.
However i also want to get the values of clientName and jobId dynamically from the form. So, i modified the query to this -
try {
var clientName = g_form.getValue('client_name');
var jobId = g_form.getValue('job_id');
var r = new sn_ws.RESTMessageV2('x_775122_enviro_tr.Get Tree Name', 'Post');
r.setStringParameterNoEscape('clientName', clientName);
r.setStringParameterNoEscape('jobId', jobId);
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthenticationProfile(authentication type, profile name);
//set a MID server name if one wants to run the message on MID
//r.setMIDServer('MY_MID_SERVER');
//if the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
But now the script doesnt work. What am i doing wrong here ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 04:50 AM
Hi @irfanshaik
Please check the Client checkbox is True and onClick function is used in the script
Regards,
Piyush Sain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 04:47 AM
Hi @irfanshaik
Have you checked the Client Checkbox on the UI action ?
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 04:50 AM
Hi @irfanshaik
Please check the Client checkbox is True and onClick function is used in the script
Regards,
Piyush Sain