Export Archives - ServiceNow Guru https://servicenowguru.com/tag/export/ ServiceNow Consulting Scripting Administration Development Mon, 04 Nov 2024 16:09:19 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.2 https://servicenowguru.com/wp-content/uploads/2024/05/cropped-SNGuru-Icon-32x32.png Export Archives - ServiceNow Guru https://servicenowguru.com/tag/export/ 32 32 Exporting Records to CSV Using ServiceNow Flow Designer https://servicenowguru.com/design/exporting-records-to-csv-using-servicenow-flow-designer/ Tue, 05 Nov 2024 10:00:22 +0000 https://servicenowguru.com/?p=17011 Exporting data from ServiceNow is a common requirement for many organizations, whether for reporting, data analysis, or integration with other systems. One of the powerful features of ServiceNow is the Flow Designer, which allows you to automate processes without writing code. In this post, we will walk through how to create a Flow in ServiceNow

The post Exporting Records to CSV Using ServiceNow Flow Designer appeared first on ServiceNow Guru.

]]>
Exporting data from ServiceNow is a common requirement for many organizations, whether for reporting, data analysis, or integration with other systems. One of the powerful features of ServiceNow is the Flow Designer, which allows you to automate processes without writing code. In this post, we will walk through how to create a Flow in ServiceNow that exports records to a CSV file.

Prerequisites

Before we begin, ensure you have the following:

– Admin access to ServiceNow: You’ll need the necessary permissions to create and manage Flows.
– Knowledge of Flow Designer: Basic understanding of how Flow Designer works.
– Records to Export: Identify the records or the table you want to export.

Step 1: Identify the Records to Export

First, determine the table from which you want to export records. For example, you might want to export incident records, change requests, or custom records. Let’s say you want to export incident records that are in the “Resolved” state.

Step 2: Create a New Flow

1. Navigate to Flow Designer: Go to the application navigator and type `Flow Designer`. Click on it to open the Flow Designer interface.

2. Create a New Flow:
– Click on `+ New` to create a new Flow.
– Give your Flow a meaningful name, such as “Export Resolved Incidents to CSV.”

 

Step 3: Add a Trigger

The Flow needs a trigger to start the process. Depending on your requirement, you can choose different types of triggers.

– Scheduled Trigger: This allows you to export records at regular intervals (e.g., daily, weekly).
– Click on `+ Add Trigger`.
– Select `Scheduled` as the trigger type.
– Configure the schedule as per your requirement, for instance, daily at midnight.

Step 4: Add an Action to Fetch Records

Now, you need to add an action to fetch the records that you want to export.

1. Add Action:
– Click on `+ Add Action` under the trigger.
– Choose `ServiceNow Core` as the action category.
– Select `Look Up Records` as the action.

2. Configure the Action:
– Choose the table from which you want to fetch records, e.g., `Incident [incident]`.
– Define the conditions to filter the records. For example, `State is Resolved`.
– Store the output in a variable, for instance, `incident_records`.

Step 5: Add an Action to Create CSV Content

To create a CSV file, you need to convert the fetched records into a CSV format.

1. Add Action:
– Click on `+` below the previous action.
– Choose `Script` as the action category.
– Select `Run Script`.

2. Write the Script:
– In the script editor, write a script that converts the records into CSV format. Here’s a sample script:

*javascript*
(function execute(inputs, outputs) {
var records = inputs.incident_records;
var csvContent = “Number,Short Description,State\n”;

records.forEach(function(record) {
csvContent += record.number + ‘,’ + record.short_description.replace(/,/g, ”) + ‘,’ + record.state + ‘\n’;
});

outputs.csvContent = csvContent;
})(inputs, outputs);

– This script assumes that you want to export the incident number, short description, and state.

 

 

Step 6: Add an Action to Save the CSV File

The next step is to save the CSV content as a file in ServiceNow.

1. Add Action:
– Click on `+` below the previous action.
– Choose `ServiceNow Core`.
– Select `Create Record`.

2. Configure the Action:
– Select `Attachment [sys_attachment]` as the table.
– Set the `Table Name` to the table where you want to attach the file, e.g., `Incident [incident]`.
– Provide a name for the file, e.g., `Resolved_Incidents.csv`.
– Set the `Content` field to the `csvContent` variable from the previous script.

Step 7: Test the Flow

Before running the Flow in production, it’s crucial to test it.

1. **Save the Flow**: Ensure all steps are configured correctly and save the Flow.

2. **Test the Flow**: Click on `Test` to manually trigger the Flow and verify that it works as expected.

Step 8: Activate the Flow

Once you have tested the Flow and confirmed it works correctly, activate it by toggling the Flow status to `Active`.

Conclusion

With this Flow in place, you now have an automated process to export records from ServiceNow to a CSV file. This Flow can be further customized to meet your specific needs, such as exporting different fields, filtering records based on more complex criteria, or integrating the export process with other workflows.

Using ServiceNow’s Flow Designer to export records is a powerful way to automate data handling, saving time and reducing manual effort. Give it a try and see how it can streamline your workflows!

The post Exporting Records to CSV Using ServiceNow Flow Designer appeared first on ServiceNow Guru.

]]>
Enabling Related List Exports in ServiceNow https://servicenowguru.com/system-ui/enabling-related-list-exports-servicenow/ https://servicenowguru.com/system-ui/enabling-related-list-exports-servicenow/#comments Wed, 23 Jul 2014 11:26:45 +0000 https://servicenowguru.wpengine.com/?p=5321 ServiceNow lists contain a lot of very nice capability that allows you to display and access data in a lot of different ways. One of these is the ability to right-click a list header and export the list data in a variety of formats…for external reporting or otherwise. For example, this is particularly useful as

The post Enabling Related List Exports in ServiceNow appeared first on ServiceNow Guru.

]]>
ServiceNow lists contain a lot of very nice capability that allows you to display and access data in a lot of different ways. One of these is the ability to right-click a list header and export the list data in a variety of formats…for external reporting or otherwise. For example, this is particularly useful as an admin when you need to export a list of records to XML and move them to another ServiceNow instance.

While this functionality works great on standard lists, it is completely absent on related lists at the bottom of records displayed in the form view. I can’t count the number of times I wished I could export a filtered related list in the same way you can with a standard list. Fortunately, with a few slight adjustments to some context menu actions in the system, there is a way!

Related List Export

The Solution…

Enabling export capability for related list records in your system can be accomplished by creating some new records in the ‘System UI -> UI Context Menus’ module in your left nav. These records are based on their existing, standard list counterparts so I can show you how to add the ‘Export -XML’ option here and you can add additional options for other formats as needed. Below is the configuration setup for the ‘Export’ menu container and the ‘XML’ export menu option.

‘Export’ UI Context Menu
Table: Global
Menu: List header
Type: Menu
Name: Export
Order: 1045
Active: True
Run onShow Script: True
Condition: ListProperties.isRelatedList() && !ListProperties.isRefList()
onShow Script:

/**
* This client-side script is used to dynamically change the context menu before it is displayed.
* It is called before showing the context menu if the Run onShow script flag is checked.
*
* The following variables are available to the script:
* 'g_menu' the context menu that is about to be shown
* 'g_item' the current context menu item
* 'g_list' the GlideList2 that the script is running against (only valid for List context menus)
* 'g_fieldName' the name of the field that the context menu is running against (only valid for List context menus)
* 'g_fieldLabel' the label of the field that the context menu is running against (only valid for List context menus)
* 'g_sysId' the sys_id of the row or form that the script is running against
*//*Hide the 'Export' context menu for defined related lists
No 'query' parameter available for accurate exports*/
if(g_list.getListName().indexOf('.REL:') > -1){
g_menu.setHidden(g_item);
}

Once you’ve added the ‘Export’ menu option for related lists as shown above, you can add options for the specific types of export options within the menu. Here is the setup for the ‘XML’ export option which you can add by navigating to ‘System UI -> UI Context Menus’ in your left navigation pane. Make sure to put it under the correct Parent menu so that it shows up where you expect!

‘XML’ UI Context Menu
Table: Global
Menu: List header
Type: Action
Name: XML
Parent: Export (Reference the record you just created above)
Order: 300
Active: True
Run onShow Script: False
Condition: gs.hasRole(‘admin’);
Action Script:

/**
* Script executed on the Client for this menu action
*
* The following variables are available to the script:
* 'g_list' the GlideList2 that the script is running against (only valid for List context menus)
* 'g_fieldName' the name of the field that the context menu is running against (only valid for List context menus)
* 'g_sysId' the sys_id of the row or form that the script is running against
* 'rowSysId' is also set to the sys_id of the row to support legacy actions, but g_sysId is preferred
*/
runContextAction();function runContextAction() {
/*Alert if context menu for defined related lists
No 'query' parameter available for accurate exports*/
if(g_list.getListName().indexOf('.REL:') > -1){
alert('Related list exports are not supported for custom defined related lists.');
return false;
}
var relField = g_list.getRelated().split(".");
var sysparm_rows = g_list.grandTotalRows;
var num_rows = parseInt(sysparm_rows);
var sysparm_query = relField[1] + "=" + gel('sys_uniqueValue').value + "^" + g_list.getQuery({orderby: true, fixed: true});var sysparm_view = g_list.view;
if (num_rows < g_export_warn_threshold) {
var dialog = new GwtPollDialog(g_list.tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_xml');
dialog.execute();
return;
}
var dialog = new GwtExportScheduleDialog(g_list.tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_xml');
dialog.execute();
}

That should be it! Once you’ve added the UI context menus, as shown above, you’ll be able to export from any related list in the system (with one exception noted below). I think that the most common use case is XML exports for admin users. If you want to enable other exports, you can combine the ‘XML’ setup provided above with the out-of-box Context menu items for CSV, XLS, or PDF.

One Exception!!!

I believe one of the reasons that this functionality isn’t included by default is that there are some related lists in the system (Defined Related Lists) that this won’t work for. The reason that Defined related Lists don’t support exports is that they don’t include a query/filter component that you can get to via the context menu. Because of this, you’ll end up exporting all of the records in the table instead of the filtered related list.

I’ve included checks in the UI Context Menu records above to disable this functionality on defined related lists in your system. While these types of lists are extremely useful they’re also much less common so it isn’t much of an issue. Here are a couple of links to help you understand more about Defined Related Lists in ServiceNow.

https://servicenowguru.com/system-definition/relationships/defined-related-lists/
http://wiki.servicenow.com/index.php?title=Creating_Defined_Related_Lists

The post Enabling Related List Exports in ServiceNow appeared first on ServiceNow Guru.

]]>
https://servicenowguru.com/system-ui/enabling-related-list-exports-servicenow/feed/ 7
Exporting Service Catalog Items in One Step https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/ https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comments Thu, 26 Jan 2012 17:54:23 +0000 https://servicenowguru.wpengine.com/?p=4277 This post comes in response to a request I received from some of my colleagues at ServiceNow to be able to export a catalog item definition to XML and transport it between instances. I’ve written before about how you can quckly export and import data between ServiceNow instances using the XML export/import context menus. While

The post Exporting Service Catalog Items in One Step appeared first on ServiceNow Guru.

]]>
This post comes in response to a request I received from some of my colleagues at ServiceNow to be able to export a catalog item definition to XML and transport it between instances. I’ve written before about how you can quckly export and import data between ServiceNow instances using the XML export/import context menus. While this works great for a lot of situations, it doesn’t work so great for data that resides in multiple tables, but really makes sense to be exported as a single unit. The components that make up a Catalog item definition are actually stored in over 21 separate tables! It is possible to export a catalog item but you have to do at least 21 separate exports to do it. In this post, I’ll show you how you can set up a UI action to export information from all 21+ tables that make up a catalog item definition…in one click!

Export Full Catalog Item

21+ tables worth of information…in ONE click!

The catalog item export will work for any table extending the ‘sc_cat_item’ table…catalog items, record producers, content items, and order guides! It DOES NOT export associated workflows, delivery plans, or wizard definitions. Workflows can be exported by following the instructions in the Graphical Workflow Export article. The following table information is included.

  • Variables (including question choices)
  • Variable sets (including associated variables, client scripts, and UI policies
  • Client scripts
  • UI policies
  • Additional categories
  • Approved by user and group
  • Available for/Not Available for lists
  • Order guide rule base

The first step is to set up a ‘Processor’ record to handle the export. ServiceNow actually has some built-in code to handle exports like this. You just have to know how to leverage it. Here’s how you would set up a processor for the catalog item export.

‘ExportCatalogItem’ Processor
Name: ExportCatalogItem
Type: Script
Path: export_catalog_item
Script:

(function process(g_request, g_response, g_processor) {
var sysid = g_request.getParameter('sysparm_sys_id');
gs.log('** Exporting Catalog Item ' + sysid);//Name all the related lists
var exporter = new ExportWithRelatedLists('sc_cat_item', sysid);
exporter.addRelatedList('item_option_new', 'cat_item');
exporter.addRelatedList('catalog_script_client', 'cat_item');
exporter.addRelatedList('catalog_ui_policy', 'catalog_item');
exporter.addRelatedList('sc_cat_item_category', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_catalog', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_user_criteria_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_user_criteria_no_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_group_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_group_no_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_company_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_company_no_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_dept_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_dept_no_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_location_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_location_no_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_user_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_user_no_mtom', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_app_group', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_app_user', 'sc_cat_item');
exporter.addRelatedList('sc_cat_item_guide_items', 'guide');
exporter.addRelatedList('pc_vendor_cat_item', 'product_catalog_item');

var catalogID = '';
var categoryID = '';
var vsrelID = '';
var vsID = '';
var vID = '';
var qcID = '';
var uipID = '';
var actID = '';
var csID = '';

//Query for Catalogs
var catalog = new GlideRecord('sc_cat_item_catalog');
catalog.addQuery('sc_cat_item', sysid);
catalog.query();
while(catalog.next()){
//Get Catalog IDs
catalogID = catalogID + ',' + catalog.sc_catalog.sys_id.toString();
}

//Query for Categories
var category = new GlideRecord('sc_cat_item_category');
category.addQuery('sc_cat_item', sysid);
category.query();
while(category.next()){
//Get Category IDs
categoryID = categoryID + ',' + category.sc_category.sys_id.toString();
}

//Query for variables to get question choices
var item = new GlideRecord('item_option_new');
item.addQuery('cat_item', sysid);
item.query();
while(item.next()){
//Query for question choices
var qc = new GlideRecord('question_choice');
qc.addQuery('question', item.sys_id.toString());
qc.query();
while(qc.next()){
//Add the variable question sys_id to the variable question string
qcID = qcID + ',' + qc.sys_id.toString();
}
}

//Query for ui catalog ui policies to get policy actions
var catpol = new GlideRecord('catalog_ui_policy');
catpol.addQuery('catalog_item', sysid);
catpol.query();
while(catpol.next()){
//Query for ui policy actions
var uipact = new GlideRecord('catalog_ui_policy_action');
uipact.addQuery('ui_policy', catpol.sys_id.toString());
uipact.query();
while(uipact.next()){
//Add the ui policy action sys_id to the ui policy action string
actID = actID + ',' + uipact.sys_id.toString();
}
}

//Query for variable set relationships
var vsrel = new GlideRecord('io_set_item');
vsrel.addQuery('sc_cat_item', sysid);
vsrel.query();
while(vsrel.next()){
//Add the item set relationship sys_id to the item set string
vsrelID = vsrelID + ',' + vsrel.sys_id.toString();
//Get the variable set
var vs = vsrel.variable_set.getRefRecord();
if(vs){
//Add the variable set sys_id to the variable set string
vsID = vsID + ',' + vs.sys_id.toString();
//Query for variables in the set
var v = new GlideRecord('item_option_new');
v.addQuery('variable_set', vs.sys_id);
v.query();
while(v.next()){
//Add the variable sys_id to the variable string
vID = vID + ',' + v.sys_id.toString();
//Query for variable question choices
var vqc = new GlideRecord('question_choice');
vqc.addQuery('question', v.sys_id.toString());
vqc.query();
while(vqc.next()){
//Add the variable question sys_id to the variable question string
qcID = qcID + ',' + vqc.sys_id.toString();
}
}

//Query for ui policies in the set
var uip = new GlideRecord('catalog_ui_policy');
uip.addQuery('variable_set', vs.sys_id.toString());
uip.query();
while(uip.next()){
//Add the ui policy sys_id to the ui policy string
uipID = uipID + ',' + uip.sys_id.toString();
//Query for ui policy actions
var uipa = new GlideRecord('catalog_ui_policy_action');
uipa.addQuery('ui_policy', uip.sys_id.toString());
uipa.query();
while(uipa.next()){
//Add the ui policy action sys_id to the ui policy action string
actID = actID + ',' + uipa.sys_id.toString();
}
}

//Query for client scripts in the set
var cs = new GlideRecord('catalog_script_client');
cs.addQuery('variable_set', vs.sys_id.toString());
cs.query();
while(cs.next()){
//Add the client script sys_id to the client script string
csID = csID + ',' + cs.sys_id.toString();
}
}
}

exporter.addQuerySet('sc_catalog', 'sys_idIN' + catalogID);
exporter.addQuerySet('sc_category', 'sys_idIN' + categoryID);
exporter.addQuerySet('io_set_item', 'sys_idIN' + vsrelID);
exporter.addQuerySet('item_option_new_set', 'sys_idIN' + vsID);
exporter.addQuerySet('item_option_new', 'sys_idIN' + vID);
exporter.addQuerySet('question_choice', 'sys_idIN' + qcID);
exporter.addQuerySet('catalog_ui_policy', 'sys_idIN' + uipID);
exporter.addQuerySet('catalog_ui_policy_action', 'sys_idIN' + actID);
exporter.addQuerySet('catalog_script_client', 'sys_idIN' + csID);
exporter.exportRecords(g_response);
})(g_request, g_response, g_processor);

Once you have your processor set up, you just need to call it. The processor above is called by its path name ‘export_catalog_item’ followed by ‘.do’. It also needs to know what to export so you need to pass it the sys_id of the top-level record that you want to export…in this case, the sys_id of the ‘Catalog item’ record.

‘Export Catalog Item’ UI Action
Name: Export Catalog Item
Table: Catalog Item (sc_cat_item)
Order: 200
Form link: True
Show insert: False
Show update: True
Client True
Hint: Export catalog item definition to .xml file
Onclick callExportCatalogItem();
Condition: gs.hasRole(“admin”)
Script:

function callExportCatalogItem() {
var url = new GlideURL('export_catalog_item.do');
url.addParam('sysparm_sys_id', gel("sys_uniqueValue").value);
var frame = top.gsft_main;
if (!frame){
frame = top;
}frame.location = url.getURL();
}

Once you’re done with this, you should have an ‘Export Catalog Item’ UI action context menu item on your ‘Catalog Item’ forms that you can use to transport catalog items, record producers, and order guides in the event that they don’t get captured in an update set.

The post Exporting Service Catalog Items in One Step appeared first on ServiceNow Guru.

]]>
https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/feed/ 44
Exporting Graphical Workflows in One Step https://servicenowguru.com/system-definition/exporting-graphical-workflows/ https://servicenowguru.com/system-definition/exporting-graphical-workflows/#comments Tue, 14 Dec 2010 18:08:50 +0000 https://servicenowguru.wpengine.com/?p=3096 While this article is still extremely useful as an example and a reference for exporting records and use of processors, the specific functionality for exporting workflow versions is now included by default in ServiceNow. The functionality was built-in starting with the Aspen release. I’ve written before about how you can quckly export and import data

The post Exporting Graphical Workflows in One Step appeared first on ServiceNow Guru.

]]>
While this article is still extremely useful as an example and a reference for exporting records and use of processors, the specific functionality for exporting workflow versions is now included by default in ServiceNow. The functionality was built-in starting with the Aspen release.

I’ve written before about how you can quckly export and import data between ServiceNow instances using the XML export/import context menus. While this works great for a lot of situations, it doesn’t work so great for data that resides in multiple tables, but really makes sense to be exported as a single unit. One example of this is Graphical Workflows. The components that make up a Graphical Workflow version are actually stored in 7 separate tables. It is possible to export a graphical workflow version but you have to do 7 separate exports to do it! In this post, I’ll show you how you can set up UI actions for some of these more complex export tasks.


The first step is to set up a ‘Processor’ record to handle the export. ServiceNow actually has some built-in code to handle exports like this. You just have to know how to leverage it. Here’s how you would set up a processor for the workflow export.

‘ExportWorkflow’ Processor
Name: ExportWorkflow
Type: Script
Path: export_workflow
Script:

//Get the sys_id of the workflow version
var sysID = g_request.getParameter('sysparm_sys_id');
//Get the sys_id of the workflow
var wfID = g_request.getParameter('sysparm_wf_id');
var actID = '';//Query for workflow activities
var act = new GlideRecord('wf_activity');
act.addQuery('workflow_version', sysID);
act.query();
while(act.next()){
actID = actID + ',' + act.sys_id.toString();
}//Export workflow version info to XML
var exporter = new ExportWithRelatedLists('wf_workflow_version', sysID);
exporter.addRelatedList('wf_stage', 'workflow_version');
exporter.addRelatedList('wf_activity', 'workflow_version');
exporter.addRelatedList('wf_condition', 'activity.workflow_version');
exporter.addRelatedList('wf_transition', 'to.workflow_version');
exporter.addRelatedList('wf_transition', 'from.workflow_version');
exporter.addRelatedList('wf_workflow_instance', 'workflow_version');
if(wfID != ''){
exporter.addQuerySet('wf_workflow', 'sys_id=' + wfID);
}
if(actID != ''){
exporter.addQuerySet('sys_variable_value', 'document_keyIN' + actID);
}
exporter.exportRecords(g_response);

Once you have your processor set up, you just need to call it. The processor above is called by its path name ‘export_workflow’ followed by ‘.do’. It also needs to know what to export so you need to pass it the sys_id of the top-level record that you want to export…in this case, the sys_id of the ‘Workflow context’ record.

‘Export to XML’ UI Action
Name: Export to XML
Table: Workflow Version (wf_workflow_version)
Order: 200
Form context menu: True
Hint: Export workflow for importing in another instance
Condition: gs.hasRole(“admin”)
Script:

action.setRedirectURL('export_workflow.do?sysparm_sys_id=' + current.sys_id + '&sysparm_wf_id=' + current.workflow);

Once you’re done with this, you should have an ‘Export to XML’ UI action context menu item on your ‘Workflow version’ form that you can use to transport workflows in the event that they don’t get captured in an update set.

The post Exporting Graphical Workflows in One Step appeared first on ServiceNow Guru.

]]>
https://servicenowguru.com/system-definition/exporting-graphical-workflows/feed/ 34
The Simple Power of XML Export/Import https://servicenowguru.com/imports/simple-power-xml-export-import/ https://servicenowguru.com/imports/simple-power-xml-export-import/#comments Thu, 04 Nov 2010 16:57:04 +0000 https://servicenowguru.wpengine.com/?p=2624 Service-now.com makes extensive use of the XML format for storing and transporting system updates and changes. Update sets, System Import Sets, and certain export methods all make use of XML files in one way or another. One feature that a lot of people don’t know about until somebody shows them is the ability to export

The post The Simple Power of XML Export/Import appeared first on ServiceNow Guru.

]]>
Service-now.com makes extensive use of the XML format for storing and transporting system updates and changes. Update sets, System Import Sets, and certain export methods all make use of XML files in one way or another. One feature that a lot of people don’t know about until somebody shows them is the ability to export and import XML files in a Service-now instance. A manual XML import/export can be extremely helpful in the right circumstances and is something that every Service-now consultant or administrator should have in their tool belt. In this post, I’ll explain how simple it is to transport system changes from one Service-now instance to another with a few clicks.

First of all, I don’t recommend using this method as a full-time replacement for update sets or import sets between instances. Those methods are much better for bulk changes and much less prone to user error when configured and used correctly. This method is completely manual, but it is really nice to know about if you’ve got something that you need to do one time – maybe something got left out of an update set or you need to pull a record from the Service-now demo instance.

It’s also critical when using this method that the sys_ids of any record you import match between the source and target if the target record needs to be updated. The sys_id is the coalesce value used to match records and indicates that an update should occur rather than an insert. This article shows how you can view the record sys_id values to make sure they match.

XML Export (Single Record from a form)

If you need to export a single record the easiest way to do it is simply to open up the record and right-click the form header as shown below. The export will ask you to save an XML file which can be imported in another Service-now instance.

XML Export (Multiple Records or Single Record from a list)

You can also export to XML from any full table list (it doesn’t work from related lists on a form). Exporting from a list allows you to filter down to multiple records (or even a single record) that you want to export. Anything that shows in the filtered list will be part of the export. The export option is accessed by right-clicking the list header as shown below.

XML Import

Once you have an XML export using one of the methods described above, you can import that XML file into any Service-now instance by right-clicking any full list header (it doesn’t work from related lists on a form) and selecting the ‘Import XML’ option. Since your XML file contains all of the details about the record(s) included you don’t have to worry about where you initiate the import from. For example, I could import a business rule export using the context menu from a list of users. The system knows from the details of the XML file where the records really need to go. It also doesn’t care if the import contains one or multiple records. The process is the same for both. Any record(s) that don’t exist in the destination instance will be created and any that already exist will be updated – AS LONG AS THE SYS_ID VALUES MATCH.

There are some cases when the functionality you are exporting is actually contained in several different tables. If you don’t have to export from these places frequently, it may be good enough simply to export from all of the individual tables as shown above. If it’s something you do frequently, you may want to consider creating a custom UI action to accomplish the task. Instructions for that can be found here.

The post The Simple Power of XML Export/Import appeared first on ServiceNow Guru.

]]>
https://servicenowguru.com/imports/simple-power-xml-export-import/feed/ 4