- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 05:22 AM
I have a custom date/time field "First action date by assigned to".
when a sc_task record is assigned to a user, then the first update made by this assigned_to user should be populated in the custom date/time field.
I tried it by using BR script
But it is not working.
Any suggestions how we can achieve this?
Appreciate any suggestions
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 02:56 PM
Hi @vivek49 ,
Business Rule Configuration
- Table: sc_task
- When to run: before update
- Conditions:
- assigned_to is not empty
- u_first_action_date_by_assigned_to is empty
- Advanced: Checked
Script:
(function executeRule(current, previous /*null when async*/) {
// Only proceed if the field is empty
if (!current.u_first_action_date_by_assigned_to) {
// Check if the user updating the record is the assigned_to user
if (gs.getUserID() == current.assigned_to.toString()) {
// Set the current date/time
current.u_first_action_date_by_assigned_to = new GlideDateTime();
}
}
})(current, previous);
Please mark this as helpful and correct, if this solves your question.
Thanks,
Yaswanth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 02:56 PM
Hi @vivek49 ,
Business Rule Configuration
- Table: sc_task
- When to run: before update
- Conditions:
- assigned_to is not empty
- u_first_action_date_by_assigned_to is empty
- Advanced: Checked
Script:
(function executeRule(current, previous /*null when async*/) {
// Only proceed if the field is empty
if (!current.u_first_action_date_by_assigned_to) {
// Check if the user updating the record is the assigned_to user
if (gs.getUserID() == current.assigned_to.toString()) {
// Set the current date/time
current.u_first_action_date_by_assigned_to = new GlideDateTime();
}
}
})(current, previous);
Please mark this as helpful and correct, if this solves your question.
Thanks,
Yaswanth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 11:00 PM
Hi @vivek49
Try the below BR configuration.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.u_first_action_date_by_assigned_to = new GlideDateTime();
})(current, previous);
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2025 05:53 AM
unless you share what you tried, we can't help
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader