- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 09:19 PM
Hi all,
Actually i have created one field on user table, so now i need to capture the time stamp into that field when user deactivated in the record and if the user activated again then the value in that field needs to clear
Please help me to achieve this
Thanks
Deepika
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 09:32 PM - edited 01-09-2024 09:33 PM
Hi @Deepika61 You can create a Before update BR with condition
Active Changes
script:
if(current.active == true){
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 09:32 PM - edited 01-09-2024 09:33 PM
Hi @Deepika61 You can create a Before update BR with condition
Active Changes
script:
if(current.active == true){
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 10:28 PM
you can use flow designer for this with no script
what did you start with?
If you are using BR then use Before update BR
Condition: Active Changes
Script: Assuming your custom field is of what Date/time type
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.active == true)
current.setValue('u_field', new GlideDateTime());
else
current.setValue('u_field','');
})(current, previous);
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 09:11 PM
Thank you for marking my response as helpful.
As per new community feature you can mark multiple responses as correct.
If my response helped please mark it correct as well so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 05:11 AM
Hi @Deepika61
Create a New Business rule
Name: Capture Deactivation Timestamp
Table: sys_user
When: Before Update
(function executeRule(current, previous) {
// Check if the user is being deactivated
if (current.active.changesTo(false)) {
// Set the timestamp field to the current date and time
current.field_name = new GlideDateTime();
} else {
// Clear the timestamp field if the user is activated again
current.field_name = null;
}
})(current, previous);