Export specific fields to XML document and attach to record

David Morden
Mega Expert

I need to create a script which will generate an XML document from specific fields on a record, and then attach that XML to the record.  This is to make data on these forms meet a new data standard that our client has to use when sending XML data to their partners.

 

So I really need to know what the javascript methods for creating the xml in SN would be (I can always do the additional homework from there), and if there are any best practices for taking the generated XML/file and attaching to the "current" record.

 

Thanks for any help.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Morden,

If you are in global scope you can use XMLDocument to create xml string.

Then use soap attachment creator to add the xml string to an xml file and to attach to the current record.

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Morden,

If you are in global scope you can use XMLDocument to create xml string.

Then use soap attachment creator to add the xml string to an xml file and to attach to the current record.

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sorry for the long delay, but I've been converting the SN data to an industry standard XML required by our customer.  Your answer was close enough to get me across the finish line, and the only difference was using the GlideSysAttachment() method to create the XML attachment record.

 

Thanks for the push in the right direction Ankur!

adriantan08
Giga Expert

Hi, dmroden.

Are you try to make an XML of the record alongside it's reference list being nested? 

How are able to achieve this? 

 

We had a requirement to deliver an XML copy of forms submitted in our SN instance to other organizations which had to meet a pre-defined data standard.  Since the form has multiple animal records also associated with it (through a related list and custom batch fill widget we made for the RP), we had to include all the RP information including the related list records associated with that form.

 

We were able to achieve this through building the XML strings as outlined above from several different GlideRecord queries to collect all of the data.  Once this was done, we set it to create the attachment in XML format so that the XML record could be sent in an automated response to the parties listed on the RP.