Create a "Time Worked" field that uses SLA start time on Incident Form

bharris
Tera Contributor

What would be the best way to create a new field called "Time Worked" that calculates how long a ticket has been opened from the SLA Start Time?  We were looking for a way to make this easily visible vs having to scroll down and click on the SLA tab.

2 REPLIES 2

Abbas_5
Tera Sage
Tera Sage

Hello @bharris,

 

To create a "Time Worked" field on a ticket form that calculates the time since the SLA Start Time, you can use a custom field with a formula that calculates the difference between the current date/time and the SLA Start Time. Here's how you might approach it: 
 
1. Create a Custom Field: 
  • Go to your ticketing system's administration/configuration settings.
  • Create a new field named "Time Worked" or something similar.
  • Set the field type to "Formula" or a similar option that allows for calculations.
2. Define the Formula: 
  • The formula will calculate the difference between the current date/time and the SLA Start Time.
  • The specific formula will depend on your ticketing system's capabilities, but it will likely involve subtracting the SLA Start Time from the current_time function.
  • If you need to display the time in a specific format (e.g., days, hours, minutes), you'll need to add formatting to the formula.
  • For example, if the SLA Start Time is in a field named "sla_start_time", you might have a formula like this (note this is an example and may need adjustments for your system):
Code
     current_time - sla_start_time
  • If you need to display the time in a more user-friendly format, you might use functions within your system to format the result.
     
3. Set Visibility: 
  • Make sure the "Time Worked" field is displayed on the ticket form where it's easily visible, such as in a prominent section or at the top of the form.
  • Consider displaying it as a "read-only" field to prevent users from manually editing the time worked value.
Example (Illustrative):
Let's say your ticketing system has the following: 
  • A field called "SLA Start Time"
  • A function to calculate the current date and time (let's call it current_time())
  • A way to format time differences (let's call it format_time())
A possible formula for the "Time Worked" field could look like this (this is a placeholder and needs to be adapted to your specific system):
Code
format_time(current_time() - sla_start_time)



If this is helpful, please hit the thumbs up button and accept the correct solution by referring to this solution in future it will be helpful to them.

Thanks & Regards,

Abbas Shaik

bharris
Tera Contributor

How would this be done in ServiceNow? Do you know what the field name is for the SLA Start time?