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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! 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 

 

1 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.

Top Tags