Captures the time it took to assign a task#1822
Captures the time it took to assign a task#1822chetnadev wants to merge 2 commits intoServiceNowDevProgram:mainfrom
Conversation
|
Hi @shreyawani98 thank you for your submission. Please note that tracking Assigned to field duration can be done with Metrics (https://www.servicenow.com/docs/bundle/xanadu-platform-administration/page/use/reporting/concept/c_SampleFieldValueDurationScript.html). That does not require a custom field and code in a business rule. I will close this PR, but feel free to create a new PR/provide additional information if you feel this BR would help others in a way that cannot be done with a Metric. |
|
To make sure you get credit for your submission. If you can add a comment in the readme along the lines of "While this is possible to do via Metrics in ServiceNow (https://www.servicenow.com/docs/bundle/xanadu-platform-administration/page/use/reporting/concept/c_SampleFieldValueDurationScript.html), the script is being provided to potentially solve some edge cases." |
|
Sure @WillemZeiler I'll add this comment in the README |
This Business Rule in ServiceNow is used to track how long it takes to assign a record after it is created, typically on a task table like Incident, Change, or a custom table.
If this is the first time the record is being assigned (i.e., u_assigned_time is empty):
Sets the field u_assigned_time to the current time.
Calculates how many minutes passed since the record was created (sys_created_on).
Stores that difference in a custom field u_time_to_assign (as a string like "15.33 minutes").
If the record was already assigned before (u_assigned_time is not empty), it just logs that and does nothing.