cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Update code for IoT Tip "How to create and configure Timers and Schedulers via JavaScript Services"

Hariharasuthan
13-Aquamarine

Update code for IoT Tip "How to create and configure Timers and Schedulers via JavaScript Services"

Re:  How to create and configure Timers and Schedulers via JavaScript Services

 

i can not update 

  • schedule
  • enabled
  • runAsUser

let params = {

name:"TestingScheduler5" /* STRING */,

description: "samplething" /* STRING */,

thingTemplateName:"Scheduler" /* THINGTEMPLATENAME */,

projectName:"MailserverGoogle" /* PROJECTNAME */,

    runAsUser:'Hariharasuthan',

schedule:'0 0/9 * * * ?',

};

 

this code can not update 

ACCEPTED SOLUTION

Accepted Solutions

let params = {
name:"Scheduler_Dynamic_CRON" /* STRING */,
description: "DEMO Scheduler With CRON dynamically set" /* STRING */,
thingTemplateName:"Scheduler" /* THINGTEMPLATENAME */,
projectName:"MailserverGoogle" /* PROJECTNAME */,
runAsUser:"Administrator",
schedule:"0 0/9 * * * ?"

};
Resources["EntityServices"].CreateThing(params);

var settings = Things["Scheduler_Dynamic_CRON"].GetConfigurationTable({
tableName: "Settings" /* STRING */
});

/** UPDATE SETTINGS **/
settings.runAsUser ="hari";
//settings.schedule = "0 0/5 * * * ?";
settings.schedule="30 08 10 06 * ?";
Things["Scheduler_Dynamic_CRON"].SetConfigurationTable({
configurationTable: settings /* INFOTABLE */,
persistent: true /* BOOLEAN {"defaultValue":true} */,
tableName: "Settings" /* STRING */
});

View solution in original post

2 REPLIES 2

The scheduler has a configuration table "Settings" where you can update values. Just call the "GetConfigurationTable" service with name "Settings" to see infos. See https://www.ptc.com/en/support/article/CS250386 for some examples.

let params = {
name:"Scheduler_Dynamic_CRON" /* STRING */,
description: "DEMO Scheduler With CRON dynamically set" /* STRING */,
thingTemplateName:"Scheduler" /* THINGTEMPLATENAME */,
projectName:"MailserverGoogle" /* PROJECTNAME */,
runAsUser:"Administrator",
schedule:"0 0/9 * * * ?"

};
Resources["EntityServices"].CreateThing(params);

var settings = Things["Scheduler_Dynamic_CRON"].GetConfigurationTable({
tableName: "Settings" /* STRING */
});

/** UPDATE SETTINGS **/
settings.runAsUser ="hari";
//settings.schedule = "0 0/5 * * * ?";
settings.schedule="30 08 10 06 * ?";
Things["Scheduler_Dynamic_CRON"].SetConfigurationTable({
configurationTable: settings /* INFOTABLE */,
persistent: true /* BOOLEAN {"defaultValue":true} */,
tableName: "Settings" /* STRING */
});

Announcements


Top Tags