export record incident to xml file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2024 12:18 PM
Hello Team
I'm trying to convert an incident record to xml file through scripting. I have a scenarios when the incident is created, it should convert the incident record to xml file. For some reason, it doesn't do anything after i hit save. I'm not sure where i can start debug this. Thanks for your help.
So i write a business rule: After, insert checked.
(function executeRule(current, previous /*null when async*/) {
var recordXml = current.toXMLString();
var attachment = new GlideSysAttachment();
var xmlBytes = recordXml.getBytes();
attachment.write(current.current.getTableName() + '_record_' + current.getUniqueValue()+ '.xml', 'text/xml', xmlBytes);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2024 01:14 PM - edited ‎10-31-2024 01:22 PM
I get 'Undefined' for:
var recordXml = current.toXMLString();
in a BR Test. The GlideRecord API doesn't support that.
https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server_legacy/c_GlideRecordAPI
As far as creating a record in the sys_attachment table, seems what you have for that won't work. Look at other OOB BRs that create records in another table. And try Google search for "servicenow export to xml script".