Comments on: Exporting Service Catalog Items in One Step https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/ ServiceNow Consulting Scripting Administration Development Tue, 28 May 2024 19:56:06 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Dennis Foster https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9161 Fri, 31 Aug 2018 13:49:42 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9161 Hi Mark – I’ve visited your pages many times and have benefited from you code, especially this one. Just thought I’d say thanks!

Dennis

]]>
By: Sam Gleske https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9160 Mon, 23 Oct 2017 03:09:10 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9160 In reply to Mark Stanger.

I created a python based exporter based on this code which can export multiple records and even a whole catalog.

https://github.com/samrocketman/servicenow-servicecatalog-exporter

]]>
By: Avi Goli https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9159 Tue, 08 Aug 2017 23:20:39 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9159 Hi,

Once I have the xml hierarchy as string, can I import it in my instance via script?
E.g.:
var url = new GlideURL(‘upload.do’);
url.addParam(‘sysparm_referring_url’, ….
url.addParam(‘sysparm_target’, g_list.getTableName());

I would like to reuse ServiceNow API (in any list view to import xml file) – but to do via script..
Where my xml record hierarchy stored in a variavle as string …

Any idea as how to do this?

Thanks,
Avi

]]>
By: Dilip Kumar DJ https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9158 Mon, 29 May 2017 14:12:24 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9158 Hi Mark,
Really helpful article and thanks for sharing this.

Is there any way by which the active flag of the exported catalog item to be made false.

Thank you.

Dilip Kumar

]]>
By: Mark Stanger https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9157 Thu, 09 Mar 2017 18:43:00 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9157 In reply to Marshall Day.

I just checked Julian’s code out again but it doesn’t seem to be working. Julian, maybe if you’re listening you could check it out and let us know what the issue might be? Here’s the code I’m using. Seems to iterate through and pause at the alert correctly but only initiates a download of the last item.

function callExportCatalogItems() {
	selSysIds = gel('dbc95612d701210050f5edcb9e61032f').getAttribute('gsft_allow');
	if (selSysIds == null || selSysIds == '') {
		selSysIds = g_list.getChecked();
	}
	
	var arrIDs = selSysIds.split(',');
	if (arrIDs.length > 1) {
		var strMsg = 'You are going to export ' + arrIDs.length + ' Items\n';
		strMsg += 'You will see a prompt for each item as it is exported, please click on OK.\n';
		strMsg += 'Without this prompt it will only export one record and not all the records you have selected';
		alert(strMsg);
	}
	
	for (var i=0; i < arrIDs.length; i++) {
		var url = new GlideURL('export_catalog_item.do');
		url.addParam('sysparm_sys_id',arrIDs[i]);
		alert('Preparing for item : ' + arrIDs[i] + '\nPlease wait until the record has downloaded before you click on OK.');
		
		var frame = top.gsft_main;
		if (!frame)
			frame = top;
		
		frame.location = url.getURL();
	}
}
]]>
By: Marshall Day https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9156 Thu, 09 Mar 2017 00:17:05 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9156 In reply to Mark Stanger.

Mark,
I reloaded the new code and everything works great…except that image part! j/k I was wondering if you had an opportunity to check out Julian Poyntz’s code for exporting multiple catalog items? I took a look and I did see some issues in the posted copy but wanted to know if you had an opinion on it.

Again, thank you for the great assist in your code from above. You have saved me a lot of time.

Marshall

]]>
By: Mark Stanger https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9155 Tue, 07 Mar 2017 23:19:20 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9155 In reply to Marshall Day.

Sorry for the delay in getting back to you on this. It’s been a pretty busy day and I had to make a couple of adjustments to this to fix some things. There isn’t a single, simple answer for how you add additional information because each table can be slightly different. If you’re just dealing with basic information in a related list you can just personalize the list control to get the list ID information necessary to add to the ‘addRelatedList’ section in the script.

I’ve fixed the catalog issue and added a couple of other tables that weren’t being included. Images unfortunately cannot be included because ServiceNow excludes those in XML exports like this. If you have any other tables that you’re noticing should be included please let me know and I’ll get the script here updated again.

]]>
By: Marshall Day https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9154 Tue, 07 Mar 2017 00:44:51 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9154 Mark,
Thank you for this amazing aid in transferring catalog items via xml. I am new to Service-Now so my depth of knowledge is growing but not anywhere close to where you are but I did want to ask a question in regards to the scripting. I am testing the processor and UI Action and it appears to work as advertised but I find that certain things do not transfer over and I am wondering if the solution is simply adding additional code to what you already have or am I missing something. My file does not transfer the icon, the picture, or the catalog that it is assigned to in the parent environment.

Any assistance would be greatly appreciated.

Marshall Day

]]>
By: Julian Poyntz https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9153 Thu, 31 Mar 2016 13:56:35 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9153 In reply to Mark Stanger.

And if you then want to make all these nice XML files into a single importable XML file, then you can use this hastily VBS routine to do the merger and it will create a combined file called “merged.xml”
The VBS needs to be in the same folder as the exported XML files

Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set outFile = objFSO.CreateTextFile(“merged.xml”, ForWriting)
intCount = 0
For Each objFile In objFSO.GetFolder(“.”).Files
If (UCase(objFile.Name) “MERGED.XML” AND UCase(objFSO.GetExtensionName(objFile.Name)) = “XML”) Then
Set inFile = objFSO.OpenTextFile(objFile, ForReading)
Do Until inFile.AtEndOfStream
strLine = inFile.ReadLine
if (intCount < 2 OR (Left(strLine,5) “<?xml" AND strLine “” AND Left(strLine, 9) “<unload u")) Then
outFile.WriteLine strLine
intCount = intCount + 1
End if
Loop
End If
Next
outFile.WriteLine "”
outFile.Close

]]>
By: Mark Stanger https://servicenowguru.com/system-definition/exporting-service-catalog-items-step/#comment-9152 Fri, 25 Mar 2016 19:30:47 +0000 https://servicenowguru.wpengine.com/?p=4277#comment-9152 In reply to Mary B.

No way that I’m aware of.

]]>