Rich Taylor · May 9, 2018

How to move defined tasks from one Instance of Cache to another

I am working with a client to try and export a set of tasks defined in the Task Manager from one system to another.  I am not seeing any API for this.  I can query this information in SQL.  So I tried to use the Data Export Wizard from the System Management portal in the SQL window.  Export was fine.  Importing failed with a "can't insert into read only field" error.  Looking at the class definition does not help since the implementation details are not visible.

So how would one accomplish this?  Export scheduled tasks from one system to another?

0 1,199
Discussion (25)3
Log in or sign up to continue

I see this in the latest version of the online docs which is version 2017.2.  obviously something was amiss in the build I was using.  

I have tried this, but the import does not work.  I get an error that only states nothing was imported.   Not terribly helpful .

I am clicking on the class and not the package in my build.  and getting what looks like package documentation.  There was obviously an issue in the build I was using.  Regardless the code for export worked.  But I can't get the import to function. Looking as exporting globals now.


Thanks for the info.  I was looking at that but could not find the global reference in the class definition or in searching the global list.  Now I know why. It's not in a global by itself.  Let me see if this will work.

Ok,  Here is the procedure that worked for me:


  • merge ^TaskList = ^SYS("Task","TaskD")
  • set sc = $System.OBJ.Export("TaskList.GBL","c:\temp\TaskList.gbl")
    • note the extension GBL is not part of the globalname.  It is used to indicate that we want to export a global
    • the file destination is completely up to you.


  • set sc = $System.OBJ.Load("c:\temp\TaskList.gbl",,.log)
  • merge ^SYS("Task","TaskD") = ^TaskList

This client is on an earlier version.

I think that using ExportTasks and ImportTasks methods of %SYS.TaskSuper class as proposed by @Sean Connelly and @John Murray would be a better solution as:

  • It would not override system tasks
  • It would produce readable XML

I agree except that the import would not work.  There is little documentation on utilizing these tools and I cannot even read the source code.

What error are you getting  from Import method?

ERROR #6037: Nothing imported.

Not terribly helpful I'm afraid.  I know that when I attempted to use SQL I was getting many Field Read Only errors.  So this may be related to that.

Can you post XML file you're trying to import?

Looks like it's empty.


Ok, I had not noticed that, but you are correct.  I had tried other methods first as I noted before and ran into issues loading onto the new systems.  I had obviously skipped the step of verifying the export file when I tried this method.  So I gather that you HAVE to pass in a list of IDS to export. Leaving it blank does not export all.  As I mentioned the documentation is extremely sparse on this api.  I will test this again later.

So I gather that you HAVE to pass in a list of IDS to export


1. Execute this to get a list of available flags and qualifiers:

Do $System.OBJ.ShowQualifiers()
Do $System.OBJ.ShowFlags()

Qualifiers are preferable to use.

2. I'd rather go with programmatic access. Write code that's:

  • Opens system task object
  • Modifies and saves it

What system task did you modify?

Let me clarify.  this has to do with the ExportTasks and ImportTasks methods of %SYS.Task class.  I need to know the qspec options that have impact on these processes.

as to question 2. The process is that they are setting up a new server for backup and want to replicate what they have setup for the current server.   Exporting and importing what is currently present is the best way.  If they are going to write a program then they could just as well  compare each existing task and do the changes manually.   There is an ongoing maintenance side to this which would also be better done with an export an import.

So to the original question is there anyway to tell ImportTasks to override the tasks that exist?

1. Import task has these two qualifiers:


They do not affect import.

2. No. If you check exported xml, you can see that exported tasks do not contain IDs, so, on import they could not overwrite existing tasks. Not sure about how correlate/next work on ID fields btw.

Exporting and importing what is currently present is the best way. 

It's the easiest way. The best way would be to write and document  a script (ObjectScript code) that transforms base instance into what they need. This way changes are documented and adding another server is easy.

I see that the ID is not in the export.  However the import does figure out how to match an import to an existing item since it does not  allow you to overwrite that existing records.  Otherwise we would see a duplication of records under new ID's.  

As far as the methods to use I would have to disagree with this recommendation.  A system administrator should not have to write code to maintain the systems under their care.  Documentation is important, however that can be accomplished with a literal document.  Then, failing to have a export/import or enterprise management  function, those changes would manually be done to all effected systems.  Writing code is less clear to everyone and is no less work.   

This feels more like a DevOps process, where coding is more acceptable. Anyway, maybe you need to ask a separate question on configuration synchronization best practices?


I had some additional questions.

  1. What are the options for qspec beyond the default 'd'?
  2. What if I want to override system defined tasks because I have adjusted things like schedules?  Is there an option to do this? qspec?

Interesting.  I am looking at Cache version 2017.1.0.792 and these classes have non of this documentation.  I will have to see if this exists on the version the customer is using.  This is how the Class reference for %SYS.Task looks on that version:

You can export/import  ^SYS("Task","TaskD") global directly, which contains task definitions data.

Some properties are computed (i.e. LastFinished), and could probably cause this error.

Try to export/import minimal set of columns.

Alternative approach would be writing code to generate tasks.

Not sure what version you are using.

In v 2017.2.1, if you edit the task, there is an export button to export the tasks.

On System Operation | Task Manager menu, there is an Import Tasks menu item.

You may have to edit the namespace name within the export if importing into a different namespace.