Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Re: How to create and configure Timers and Schedulers via JavaScript Services
i can not update
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
Solved! Go to Solution.
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 */
});
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 */
});