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
Advantage Sleep CentersAdvantage Sleep Centers 

Need assistance with a countUP timer

Good afternoon all,

I'm trying to create a countup timer. I need a timer that counts the seconds, minutes, and hours while working within an object. When the object is closed it should save the time spent... when it is reopened the clock countup should start where it was left off. I would need an override button to cease all counting.

Thank you,
-Adam
TobyKutlerTobyKutler
Depending on your need you can either put a Lightning web component on the record page or put it on a start and stop button. Assuming you want the clock to be automated you can start the lightning components clock when the user is directed to the page and when the user leaves the page save the time to a field (you may need a custom junction object for this). You will need to use the connectedCallback() and disConnectedCallback when the component initializes and is removed from the DOM respectively.  Take a look at this thread for how to create the timer backend and UI (https://developer.salesforce.com/forums/?id=9062I000000Qx62QAC).