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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to create and configure Timers and Schedulers via JavaScript Services

Hariharasuthan
13-Aquamarine

How to create and configure Timers and Schedulers via JavaScript Services

As per the Original Post

 

 

hi expert 

 I need sent mail  how do write script , event how to add please structure of program

ACCEPTED SOLUTION

Accepted Solutions

var params = {
name:"Scheduler_Dynamic_CRON139l1" /* STRING */,
description: "DEMO Scheduler With CRON dynamically set" /* STRING */,
thingTemplateName:"MyCustomScheduler" /* THINGTEMPLATENAME */,
projectName:"MailserverGoogle" /* PROJECTNAME */,
runAsUser:"Hariharasuthan",
schedule:"0 0/5 * * * ?"
};


result = 'thing doesnt exist';
let thingName = params.name;
if (Things[thingName])
{
//Things[thingName].Enable();
result = 'thing exist';
Things[thingName].EnableThing();
Things[thingName].RestartThing();
logger.warn("thing exist "+thingName);
}
else
{
result="new one";
Resources["EntityServices"].CreateThing(params);
logger.warn("Thing Created: "+thingName);
Things[thingName].EnableThing();
Things[thingName].RestartThing();
}
var settings = Things[thingName].GetConfigurationTable({
tableName: "Settings" /* STRING */
});

/** UPDATE SETTINGS **/
settings.runAsUser = params.runAsUser;
//settings.schedule = "0 0/5 * * * ?";
settings.schedule=params.schedule;
Things[thingName].SetConfigurationTable({
configurationTable: settings /* INFOTABLE */,
persistent: true /* BOOLEAN {"defaultValue":true} */,
tableName: "Settings" /* STRING */

});
//Things[thingName].Enabled();
logger.warn("Thing Setting Update "+thingName);
// Things[thingName].Enabled();

View solution in original post

2 REPLIES 2

Hi @Hariharasuthan 

 

Hi @Hariharasuthan.

 

There are a number of articles in IoT Tips that may be helpful.  This is a good one to start with.  

 

This article from our Knowledge Base may also be helpful.

 

Please let us know if you have any questions after reviewing this information.

 

Regards.

 

--Sharon

var params = {
name:"Scheduler_Dynamic_CRON139l1" /* STRING */,
description: "DEMO Scheduler With CRON dynamically set" /* STRING */,
thingTemplateName:"MyCustomScheduler" /* THINGTEMPLATENAME */,
projectName:"MailserverGoogle" /* PROJECTNAME */,
runAsUser:"Hariharasuthan",
schedule:"0 0/5 * * * ?"
};


result = 'thing doesnt exist';
let thingName = params.name;
if (Things[thingName])
{
//Things[thingName].Enable();
result = 'thing exist';
Things[thingName].EnableThing();
Things[thingName].RestartThing();
logger.warn("thing exist "+thingName);
}
else
{
result="new one";
Resources["EntityServices"].CreateThing(params);
logger.warn("Thing Created: "+thingName);
Things[thingName].EnableThing();
Things[thingName].RestartThing();
}
var settings = Things[thingName].GetConfigurationTable({
tableName: "Settings" /* STRING */
});

/** UPDATE SETTINGS **/
settings.runAsUser = params.runAsUser;
//settings.schedule = "0 0/5 * * * ?";
settings.schedule=params.schedule;
Things[thingName].SetConfigurationTable({
configurationTable: settings /* INFOTABLE */,
persistent: true /* BOOLEAN {"defaultValue":true} */,
tableName: "Settings" /* STRING */

});
//Things[thingName].Enabled();
logger.warn("Thing Setting Update "+thingName);
// Things[thingName].Enabled();

Announcements


Top Tags