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
As per the Original Post.
hi expert
I need sent mail how do write script , event how to add please structure of program
Solved! Go to Solution.
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();
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();