Skip to content

Conversation

@chetnadev
Copy link
Contributor

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.

@WillemZeiler WillemZeiler self-assigned this Oct 5, 2025
@WillemZeiler
Copy link
Contributor

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.

@WillemZeiler
Copy link
Contributor

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."
With that addition, you can resubmit the PR and we can approve it.

@chetnadev
Copy link
Contributor Author

Sure @WillemZeiler I'll add this comment in the README

@chetnadev chetnadev deleted the srules25 branch October 5, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants