Skip to main content
13-Aquamarine
April 4, 2023
Solved

How to implement separate schedules for each user

  • April 4, 2023
  • 1 reply
  • 2742 views

dear  all expert 

i plan to multiple users  dynamic scheduling every user separate scheduling time how to implement. i have done for single user   email sent massage scheduling. but how did multiple user and dynamic scheduling  email sent .

 

 

 

Best answer by wcui

Try below code to dynamically create scheduler thing.

------------------------------------------------------------------------

var ThingName = "yourThingName";
var params = {

name: ThingName /* STRING */,

description: undefined /* STRING */,

thingTemplateName: 'Scheduler' /* THINGTEMPLATENAME */,

projectName: 'PTCDefaultProject' /* PROJECTNAME */,

tags: undefined /* TAGS */

};

try{

Resources["EntityServices"].CreateThing(params);

logger.warn("Thing Created: "+ThingName);

Things[ThingName].EnableThing();

updateThing();

Things[ThingName].RestartThing();

Things[ThingName].EnableScheduler();

}

catch(e){

logger.warn("Exception"+e);

}

function updateThing(){

var configtable = Things[ThingName].GetConfigurationTable({tableName: "Settings"});

 

// update configuration with service parameters

 

configtable.schedule = '0 0/10 * * * ?';

configtable.runAsUser = 'Administrator';

configtable.enabled = true;

// set new configuration table

 

var par= {

configurationTable: configtable /* INFOTABLE */,

persistent: true /* BOOLEAN */,

tableName: "Settings" /* STRING */

 

};

Things[ThingName].SetConfigurationTable(par);

}

1 reply

19-Tanzanite
April 4, 2023

Hi @Hariharasuthan 

 

Could you please elaborate on your use case? 

 

Also, give some information on the below question 

1. How many users will be using this feature 

2. How do users define scheduling time from UI / Mashup?

 

/ VR

 

13-Aquamarine
April 4, 2023

hi @Velkumar 

 answer question 

1.N number of users use feature. , (Multiple user multiple chose the (hour,day,week,year,) all are separate  configuration  )

 2, define user from UI/mashup ( hour ,week  ,month ,year ) scheduling save value to SQL server 

          use case. Elaboration:

n number of users continuously joint in database, each user some configuration need configuration means report sent to the mail time periods(hour,day,month,year) this store value from sql server , N0 user one hour sent mail N1 user two hours N3 user one day N4 user week  N5 user month N6 user year N number of user all are (hour, day,week ,month ,year) based 

for example :

n1 user sent mail every one hour 

n2 user sent mail end of day 

n3 user sent mail weekly once 

n4 user sent mail monthly once 

n5 user sent mail yearly once 

 

requirement 

 i attempted to single user scheduling (hour,day,month,year) sent mail successfully. run on this concept.  ,but n number of user how to implement scheduling. 

 

With Regards 

Hariharasuthan