Skip to main content
12-Amethyst
December 18, 2023
Solved

How to get time when a Particular service get executed

  • December 18, 2023
  • 1 reply
  • 1855 views

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

Best answer by Arun_C

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

 

1 reply

16-Pearl
December 18, 2023

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

12-Amethyst
December 18, 2023

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

Arun_C16-PearlAnswer
16-Pearl
December 18, 2023

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