
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-12-2018 06:24 PM
Looking for an alternative to GlideRecordXMLSerializer() for a scoped application. Looking to get the entire XML of the glide record.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-13-2018 01:26 PM
Try this;
Create a script include under the global application that is accessible from all application scopes and paste this in as the script.
var ScopedXmlSerializer = Class.create();
ScopedXmlSerializer.prototype = {
initialize: function() {
},
serialize:function(currentRecord)
{
var xmlSerializer = new GlideRecordXMLSerializer();
return xmlSerializer.serialize(currentRecord);
},
type: 'ScopedXmlSerializer'
};
I tested in a background script and selected run script in scope <some scope that isn't global> with the following:
var current = new GlideRecord("sys_user");
current.setLimit(1);
current.query();
current.next();
var xml = new global.ScopedXmlSerializer();
var xmlString = xml.serialize(current);
gs.info(xmlString.toString());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-12-2018 09:25 PM
You can use
var json = new global.JSON().encode(object);
to encode object to JSON.
Please check below blog for additional details
https://community.servicenow.com/community?id=community_blog&sys_id=235e2eaddbd0dbc01dcaf3231f961929
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-13-2018 12:21 PM
The problem is I don't have an object I have a glide record and I'm looking to get all the xml for that record to pass to another application (external web service).
This GQL solution seem like a lot of overhead, do you have any additional details about this solution?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-13-2018 01:00 PM
Why don't you glide the record and get all required field data for sending to external WSDL?
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-13-2018 01:26 PM
Try this;
Create a script include under the global application that is accessible from all application scopes and paste this in as the script.
var ScopedXmlSerializer = Class.create();
ScopedXmlSerializer.prototype = {
initialize: function() {
},
serialize:function(currentRecord)
{
var xmlSerializer = new GlideRecordXMLSerializer();
return xmlSerializer.serialize(currentRecord);
},
type: 'ScopedXmlSerializer'
};
I tested in a background script and selected run script in scope <some scope that isn't global> with the following:
var current = new GlideRecord("sys_user");
current.setLimit(1);
current.query();
current.next();
var xml = new global.ScopedXmlSerializer();
var xmlString = xml.serialize(current);
gs.info(xmlString.toString());