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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

How to fetch 7 update scheduletime of scheduler using services?

AP_10343008
15-Moonstone

How to fetch 7 update scheduletime of scheduler using services?

1. How to fetch scheduletime of scheduler using services?

2. How to update scheduletime of scheduler using services

AP_10343008_0-1728912371156.png

 

ACCEPTED SOLUTION

Accepted Solutions

// getting the config table
let table=Things["sched1"].GetConfigurationTable({tableName:"Settings"});

// setting the value
table.schedule="0 4 0/1 * * ?";
Things["sched1"].SetConfigurationTable({
	tableName: "Settings", configurationTable: table,
});

// returning the value
result=Things["sched1"].GetConfigurationTable({tableName:"Settings"}).schedule;

View solution in original post

10 REPLIES 10

// getting the config table
let table=Things["sched1"].GetConfigurationTable({tableName:"Settings"});

// setting the value
table.schedule="0 4 0/1 * * ?";
Things["sched1"].SetConfigurationTable({
	tableName: "Settings", configurationTable: table,
});

// returning the value
result=Things["sched1"].GetConfigurationTable({tableName:"Settings"}).schedule;
AP_10343008
15-Moonstone
(To:Rocko)

If I updated the value "0 44 11 ? * WED" for scheduled time through service, subscription is not triggering automatically. But If i manually update scheduler with the same  scheduled time "0 44 11 ? * WED" subscription is triggering automatically. What is the issue.

Try to restart the scheduler thing after the update.

This is the code i used to set the scheduler. The CRON String is updating correctly. But subscription is not triggering.

Code:

try{
TimeInHours = parseInt(TimeInHours);
let DayofWeekValueArray = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
const exists = DayofWeekValueArray.includes(DayOfWeekValue);
 
if(exists==true && TimeInHours<24 && TimeInMinutes<60){
    // getting the config table
    let table=Things["AutoGenerationReport-Scheduler"].GetConfigurationTable({tableName:"Settings"});
    let CRONString = "0 "+TimeInMinutes+" "+TimeInHours+" ? * "+DayOfWeekValue;
    logger.info("SetScheduledTime: CRONString is "+CRONString);
    // setting the value
    table.schedule=CRONString;
    table.enabled = enabled;
    Things["AutoGenerationReport-Scheduler"].SetConfigurationTable({
        tableName: "Settings", configurationTable: table, persistent: true
    });
    result=true;
}
    else  result=false;
}catch(e){
logger.warn("SetScheduledTime: error is "+e+" in linenumber "+e.lineNumber);
    result=false;
}

Try to call Things["AutoGenerationReport-Scheduler"].RestartThing(); right before setting result to true.

Yes. It is working now. Thank you.

I'll get that added to the article.

AP_10343008
15-Moonstone
(To:Rocko)

How to find the services of Datashapes, Projects, ModelTags services quickly? Any documentation is there to go through all of these services in one go ?

Not sure what you mean. That is what the Services tab is for?

Plus you can consult the API documentation: http://support.ptc.com/help/thingworx_hc/javadoc/

 

Announcements


Top Tags