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 get time when a Particular service get executed

LY_10691079
12-Amethyst

How to get time when a Particular service get executed

Hi Everyone,

 

My Doubt is like suppose I have a service which store windchill data into Thingworx database from so what is I want is schedule a time on that service so that it will automatically get executed on each specified time interval for that I know there is auto refresh widget in thingworx but How will I get the timing that when this service get executed like I am Thiking to create a property (Date Time) which store the recent time when the service get executed so to to this what I have to do Like any code change or something else 

 

please suggest if anyone have any idea.

 

Thanks and Regards,

Lav

ACCEPTED SOLUTION

Accepted Solutions

HI @LY_10691079 ,

 

Based on your explanation please add this below piece of code at starting of your service. Also please check the property is Persistant.

 

me.Lastupdates = new Date();

 

 It will log the Date Time value in that property at the time of execution when that service is trigger.

 

Thanks & Regards,

Arun C

 

View solution in original post

5 REPLIES 5

Hi @LY_10691079 ,

 

If you are creating Persist property/properties to store the service execution time, then add that created property in your store service code & assign current date time to find it.

 

For example:

 

///***/// TOP : ASSINGING CURRENT TIME TO FIND SERVICE START ///***///
Things[<<PROPERTY THING NAME>>].ServiceExectionStartTime = new Date();

..............<<<YOUR EXSITING CODE>>>..............

///***/// BOTTOM : ASSINGING CURRENT TIME TO FIND SERVICE END TIME ///***///
Things[<<PROPERTY THING NAME>>].ServiceExectionEndTime = new Date();

 

I hope it clarifies your doubt.

 

Thanks & Regards,

Arun C

LY_10691079
12-Amethyst
(To:Arun_C)

Hi @Arun_C ,

 

I have created a property NAME as Lastupdates on the same thing on which this store service is created and given Base Type as Datetime now  according to you I 

should be adding the piece of code which you given above in the store service and in the bottom of store service to check the time right?

 

but how it will store the time in that particular property like I am not sure 

and even I tried this service 

 

 

///***/// TOP : ASSINGING CURRENT TIME TO FIND SERVICE START ///***///
Things[<<PROPERTY THING NAME>>].Lastupdates.StartTime = new Date();

..............<<<YOUR EXSITING CODE>>>..............

///***/// BOTTOM : ASSINGING CURRENT TIME TO FIND SERVICE END TIME ///***///
Things[<<PROPERTY THING NAME>>].Lastupdates.EndTime = new Date();

 

 

executing the service but not able to see the time and data in the property

 

and please be remember I don't want execution time, I want when the services  executed that time and date.

 

Thanks and Regards,

Lav

HI @LY_10691079 ,

 

Based on your explanation please add this below piece of code at starting of your service. Also please check the property is Persistant.

 

me.Lastupdates = new Date();

 

 It will log the Date Time value in that property at the time of execution when that service is trigger.

 

Thanks & Regards,

Arun C

 

LY_10691079
12-Amethyst
(To:Arun_C)

Great I am getting the time Now I want to show that time to mashup UI 

 

so to do so What I have to do and one more thing like for auto execution like service should be triggering automatically after a certain Interval of time 

do I have to add a scheduler template or timer template or auto refresh  widget you can give me suggestion 

 

thank you so much!

for answering my doubts!

 

Hi @LY_10691079 ,

 

You can use the default service in the same Thing called 'GetDateTimePropertyValue' to display the property value by calling it in UI/Mashup level.

 

Please proceed by creating a Scheduler Thing and schedule the time interval if it has to execute in backend automatically. Then add Subscription by calling the store service inside in the ScheduleEvent.

 

Thanks & Regards,

Arun C

Announcements


Top Tags