Skip to main content

Exporting Folder Items Programmatically

Exporting Folder Items Programmatically

To export folder items programmatically, use the following command:

Do ##class(%DeepSee.UserLibrary.Utils).%Export(itemname,filename)

Where:

  • itemname is the full name of the item, including the folder in which it belongs.

    • For a pivot table, append the extension .pivot

    • For a dashboard, append the extension .dashboard

    • For a widget, append the extension .widget

    • For a theme, append the extension .theme

  • filename is the full path and file name of the file to create. InterSystems suggests that you end the file name with .xml, because the file is an XML file.

For example:

 set DFIname="Chart Demos/Area Chart.pivot"
 set filename="c:/test/Chart-Demos-Area-Chart-pivot.xml"
 do ##class(%DeepSee.UserLibrary.Utils).%Export(DFIname,filename)

 set DFIname="KPIs & Plugins/KPI with Listing.dashboard"
 set filename="c:/test/KPIs-Plugins-KPI-with-Listing-dashboard.xml"
 do ##class(%DeepSee.UserLibrary.Utils).%Export(DFIname,filename)

Alternative Technique (for Exporting Multiple Items)

To export multiple items programmatically into a single XML file, use the $system.OBJ.Export() method. The first and second arguments for this method are as follows:

  • items is a multidimensional array as follows:

    Array Node Node Value
    items("full-folder-item-name.DFI") where items is the name of the array and full-folder-item-name.DFI is the full name of the folder item, exactly as seen in Studio, including case. ""

    Note that because this argument is a multidimensional array, you must precede it with a period when you use the $system.OBJ.Export() method.

  • filename is the full path and file name of the file to create. InterSystems suggests that you end the file name with .xml, because the file is an XML file.

For example:

 set items("Chart Demos-Area Chart.pivot.DFI")=""
 set items("Chart Demos-Bar Chart.pivot.DFI")=""
 set items("Chart Demos-Bubble Chart.pivot.DFI")=""
 set filename="c:/test/Chart-Samples.xml"
 do $system.OBJ.Export(.items,filename)

You can also use this method to export other items such as classes; for details, see the Class Reference for %SYSTEM.OBJOpens in a new tab.

FeedbackOpens in a new tab