script not working from BR/workflow
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2024 10:07 PM
Hi All,
I'm trying to generate a dynamic excel attachment from script. It is working perfectly fine but not from BR/workflow.
And also I'm getting all the logs with perfect value. Please suggest how to make it work from BR n workflow.
var selected_inc = "INC0000029,INC0000028,INC0000024,INC0000055";
var query = "incident_list.do?EXCEL&sysparm_query=numberIN"+selected_inc;
var instance_name = gs.getProperty('instance_name');
gs.print("query abdul" + instance_name +" " + query);
var sys_id ="b088ecfc2f3b3510c4fcfe1df699b69f";
try {
var request = new sn_ws.RESTMessageV2();
var instanceUrl = "https://"+instance_name+".service-now.com/";
gs.print('url abdul'+instanceUrl + query);
request.setEndpoint(instanceUrl + query);
request.setHttpMethod("GET");
var user = "admin";
var password = "ABCD";
request.setBasicAuth(user, password);
//request.setRequestHeader("Accept", "application/json");
gs.print("before resonse abdul");
request.saveResponseBodyAsAttachment("sc_req_item",sys_id,'resolved_incidents.xls');
gs.print("after resonse abdul ");
var response = request.execute();
var httpStatus = response.getStatusCode();
gs.print(httpStatus);
} catch (ex) {
var message = ex.getMessage();
gs.print(message);
}
-Abdul Musavvir
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 06:47 AM
when should this be generated?
what's the error you are getting?
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 06:49 AM
@Ankur Bawiskar It is not throwing any error. Script is executing perfectly and I'm receiving all logs with correct values.
The attachment must be attached once the RITM is closed.