Want to save update set xml exported as an attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 04:08 PM
Hello friends,
I have been using the "Export to XML" UI action on update set and now for some experimentational purpose I would like to save the XML to any of the ServiceNow record as an attachment. I had a look at the UI action "Export to XML" and found that there is a redirectURL. I tried to mimic the same using the REST GET Method and saving the output as an attachment to any of the record. But getting an 401 Unauthorized Error.
var current=new GlideRecord("sys_update_set");
current.get("f35cf0c507130110e835ff808c1ed07b");
var updateSetExport = new UpdateSetExport();
var sysid = updateSetExport.exportUpdateSet(current);
var url= "https://devxxx.service-now.com/export_update_set.do?sysparm_sys_id="+sysid+"&sysparm_delete_when_done=true&sysparm_ck=31ceffc107301110e835ff808c1ed0c566ce23842b976f8790d7ebde2f04d824dcdf0afe"
var request = new sn_ws.RESTMessageV2();
request.setEndpoint(url);
request.setHttpMethod('GET');
var user = gs.getProperty("CommitUser");
var password = gs.getProperty("CommitUserPassword");
request.setBasicAuth(user, password);
request.setRequestHeader("Accept", "application/json");
var updatesetid = request.saveResponseBodyAsAttachment(current.getTableName(), current.sys_id, current.getValue('name') + ".xml");
var response = request.execute();
var httpStatus = response.getStatusCode();
Rahul
- Labels:
-
Platform and Cloud Security
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2023 07:15 AM
Hello michaelward,
I'm currently facing the same issue since San Diego patch10-01-12-2023.
Is there an update to this problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2023 07:23 AM
I didnt not continue on this. I am sorry...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2024 04:02 AM - edited ‎12-14-2024 10:57 AM
We have received the similar error when click on "Export to XML" on the new version. The solution was to replace the UI action script by passing the "&sysparm_is_remote=false&sysparm_ck=" + gs.getSessionToken()" parameters. That is by replacing the line
action.setRedirectURL("export_update_set.do?sysparm_sys_id=" + sysid + "&sysparm_delete_when_done=true");
with
"action.setRedirectURL("export_update_set.do?sysparm_sys_id=" + sysid + "&sysparm_delete_when_done=true&sysparm_is_remote=false&sysparm_ck=" + gs.getSessionToken());"
You can refer the UI Action from the latest release for the script inside "Export to XML" UI Action
Refer the below KB article for more information:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1116189
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2024 04:01 AM - edited ‎12-14-2024 10:58 AM
We have received the similar error when click on "Export to XML" on the new version. The solution was to replace the UI action script by passing the "&sysparm_is_remote=false&sysparm_ck=" + gs.getSessionToken()" parameters. That is by replacing the line
action.setRedirectURL("export_update_set.do?sysparm_sys_id=" + sysid + "&sysparm_delete_when_done=true");
with
"action.setRedirectURL("export_update_set.do?sysparm_sys_id=" + sysid + "&sysparm_delete_when_done=true&sysparm_is_remote=false&sysparm_ck=" + gs.getSessionToken());"
You can refer the UI Action from the latest release for the script inside "Export to XML" UI Action
Refer the below KB article for more information:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1116189