Question
· 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?

Discussion (25)3
Log in or sign up to continue

That's the doc for the %SYS.Task package. One row above it in the Documatic explorer panel you'll find the link to the %SYS.Task class. Here's a link to the online copy for 2017.1

http://docs.intersystems.com/cache20171/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25SYS.Task

I'm seeing ExportTasks and ImportTasks methods, both inherited from %SYS.TaskSuper

Ok,  Here is the procedure that worked for me:

Export:

  • 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.

Import

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

Eduard,

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.

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:

displayerror
displaylog

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.