function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fabio MilheiroFabio Milheiro 

Is it possible to create timers in objects? Any alternative?

The company needs to know how much time each worker spends on each part of each project part.

The following resembles some custom objects that were defined for this app:

  • Custom Project
  • Custom Project Part
  • Custom Time Entry

Now we need to customize our salesforce app in such a way that a worker can open the project part and click "Start..." and later "Stop...".

These buttons would create a time entry with a start date and update the time entry with a stop date respectively.

 

Is this possible to do in the custom objects themselves? (ideal)

 

Ant other alternative?

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

Solution may look weird

 

Create fields:

1)Start Date/Time

2) Stop Date/Time

3) Boolean

4) Formula which is a subtraction of time between Start Date/Time and Stop Date/Time

 

Custom button to manage all these. When hit first will check the Boolean value, if false then enter present date/time in start date/time field and make the Boolean true.

 

If true then enter present date/time in stop date/time. And your formula will do rest.

 

OR

 

Just create

1) Date/Time field

2) Text field to hold the time difference

 

Now custom logic which will be executed each time a button is hit. Logic will check if the Date/Time field is blank then fill the present date/time in it and do nothing. If Date/Time field have the value then calculate the difference between now and entered value and then enter that value in Text Field.

 

You can then show that text field wherever you want. I can just think of this at 1.30 Am in the morning.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

 

 

All Answers

Ankit AroraAnkit Arora

Solution may look weird

 

Create fields:

1)Start Date/Time

2) Stop Date/Time

3) Boolean

4) Formula which is a subtraction of time between Start Date/Time and Stop Date/Time

 

Custom button to manage all these. When hit first will check the Boolean value, if false then enter present date/time in start date/time field and make the Boolean true.

 

If true then enter present date/time in stop date/time. And your formula will do rest.

 

OR

 

Just create

1) Date/Time field

2) Text field to hold the time difference

 

Now custom logic which will be executed each time a button is hit. Logic will check if the Date/Time field is blank then fill the present date/time in it and do nothing. If Date/Time field have the value then calculate the difference between now and entered value and then enter that value in Text Field.

 

You can then show that text field wherever you want. I can just think of this at 1.30 Am in the morning.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

 

 

This was selected as the best answer
Fabio MilheiroFabio Milheiro

Hey mate,

 

I had gotten to that solution (the first) but thanks.

 

Fabio