Skip to Content
avatar image
Former Member

How to update an xsjob file using xsjs?

I have an xsjob file like below.

{
    "description": "Send an email",
    "action": "MyPath.XSJS:sendEmailTest.xsjs::sendEmail",
    "schedules": [
       {
          "xscron":"* * * * 19 09 0"
       },
       {
          "xscron":"* * * * 19 10 0"
       }
    ]
}

I want to be able to add/delete schedules dynamically using xsjs. I have XS classic so I'm referencing the following jsdoc jobs. Looking at the .jobs namepsace I can reference an xsjob like this.

var myjob = new $.jobs.Job({uri:"my.xsjob", sqlcc:"sqlcc/otheruser.xssqlcc"});

This is my code

try {
       
       var jobPath = '/Development/KJH0074/XSJS/testJob.xsjob';
       var myJob = new $.jobs.Job({uri: jobPath}); //this line doesn't work
       
       myJob.schedules.add({
                description: 'Add new schedule',
                "xscron":"* * * * 20 10 0"
            });
            
     }catch (e) {
          $.response.status = $.net.http.INTERNAL_SERVER_ERROR;
          $.response.setBody(e.message);
     }


I'm only entering the uri parameter as I don't know what the sqlcc is. I'm able to update the xsjob file manually but I can't do it through XSJS. Has anyone done this before? If anyone has some ideas about doing this please share.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers