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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

how to add runAsUser:'Hariharasuthan', schedule:'0 0/9 * * * ?', in dynamic scheduler

Hariharasuthan
12-Amethyst

how to add runAsUser:'Hariharasuthan', schedule:'0 0/9 * * * ?', in dynamic scheduler

dear all expert 

 

 

let params = {
name: 'TestingScheduler9000' /* STRING */,
description: 'samplething' /* STRING */,
thingTemplateName:'Scheduler' /* THINGTEMPLATENAME */,
projectName:'MailserverGoogle' /* PROJECTNAME */,
runAsUser:'Hariharasuthan',
schedule:'0 0/9 * * * ?',
};
let result=params;
// no return
Resources["EntityServices"].CreateThing(params);

Hariharasuthan_0-1681188013796.png

runAsUser:'Hariharasuthan', schedule:'0 0/9 * * * ?', both are not update ,how to update 

 

ACCEPTED SOLUTION

Accepted Solutions

hope it will be helpful.

/** CREATE AND ENABLE SCHEDULE THING **/
	//create thing code
/** GET SETTINGS **/
var settings = Things["Scheduler_Scheduler"].GetConfigurationTable({
	tableName: "Settings" /* STRING */
});

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

View solution in original post

3 REPLIES 3

hope it will be helpful.

/** CREATE AND ENABLE SCHEDULE THING **/
	//create thing code
/** GET SETTINGS **/
var settings = Things["Scheduler_Scheduler"].GetConfigurationTable({
	tableName: "Settings" /* STRING */
});

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


let params = {
name:"TestingScheduler999" /* STRING */,
description: "samplething" /* STRING */,
thingTemplateName:"Scheduler" /* THINGTEMPLATENAME */,
projectName:"MailserverGoogle" /* PROJECTNAME */,
runAsUser:'Hariharasuthan',
schedule:'0 0/9 * * * ?',
};

Resources["EntityServices"].CreateThing(params);
Things["TestingScheduler999"].Enabled();
var settings = Things["TestingScheduler999"].GetConfigurationTable({
tableName: "Settings" /* STRING */
});

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

 

return error: 

1. Error executing service testthing. Message :: TypeError: Cannot call property Enabled in object com.thingworx.things.scheduler.SchedulerThing@4f6b8821. It is not a function, it is "boolean". - See Script Error Log for more details.

 

 

 

.create thing()

.enable thing()

. restart thing()

 

Then use previous code.

Announcements


Top Tags