Help with Exporting XML of a record and its related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 11:03 AM
The task at hand is to export an XML of a record and its related lists. I am implementing it for the following ITSM tables: incident, change, and problem.
After reading through many articles I've come across an OOB script include called: ExportWithRelatedLists and I know this would be the best approach.
I am trying to utilize the script include in a server side UI action, however I get this error: access denied ("java.io.FilePermission" "undefined" "write").
These are my UI Action configurations:
Any pointers to my UI Action script would be immensely helpful:
var exporter = new ExportWithRelatedLists('incident', current.sys_id);
exporter.addRelatedList('task_sla', 'task');
exporter.addRelatedList('task_ci', 'task');
exporter.addRelatedList('task_cmdb_ci_service', 'task');
exporter.addRelatedList('task_service_offering', 'task');
exporter.addRelatedList('incident', 'parent_incident');
exporter.addRelatedList('sc_request', 'parent');
exporter.addRelatedList('interaction_related_record', 'task');
exporter.setAttachments(true); // Enable attachment support if required
var attachment = new GlideSysAttachment();
//set up inputs
var rec = new GlideRecord('incident');
rec.get(current.sys_id);
var fileName = 'example.xml';
gs.info("1Testing_c_" + current.sys_id);
var response = gs.context.getResponse();
//this exportRecords is giving me the issue
exporter.exportRecords(response);
gs.info("1Testing_d_" + current.sys_id);
var contentType = 'text/xml';
//example content to see if the xml attachment works
var content = "<access>package_private</access>"
// var content = exporter.exportRecords();
var agr = attachment.write(rec, fileName, contentType, content);
gs.info('1Testing The attachment sys_id is: ' + agr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 11:24 AM
Hi @Arnab18 ,
Check the ACL ( write ) on sys_attachment table, seems like role/permission issue here.
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 11:53 AM
@AshishKM I'm not impersonating anyone. I am running the UI Action as a sys_admin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 07:16 AM
Hi @Arnab18 ,
There are some OOTB "Export" UI Action available, you can refer the same to achieve the same result.
Here, the main issue observed none of UI Action ( OOTB ) has entire code in it instead UI Action send the call to processor using query parameter which is executed by matched processor by system using maint permission.
You can try to replicate same way, you have to modify the create ACL on sys_processor table to allow insert new record, OOTB it's for maint only
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 06:38 AM
As an update the requirements has changed due to the complexity of the solution. I did modify the ACL and tried replicating the UI action to one of the Export records in the screenshot, however nothing worked. Thanks for your help tho!