Radio Buttons Creating Time Stamps?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 07:07 AM
Good Morning All,
I've searched but can't find anyone asking about a way to use radio buttons to create a visible time/date stamp. Right now, I am using a form log where radio buttons are used for showing start and completion of a task. Currently the creation of the task log "created" is being used for a start time and "modified" is being used for an end time, however in situations where a task is complete but the record needs adjustment after the fact, the "modified" time does not work.
Is there a way to have when the radio button is selected a time/date stamp is recorded visibly?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2025 10:10 PM
Yes! You can achieve this in ServiceNow by using Client Scripts to capture timestamps when a radio button is selected and store them in visible fields.
✅ Solution Approach
- Add two new date/time fields (start_time and completion_time) to the form.
- Use an onChange Client Script to capture the timestamp when the user selects a radio button.
✅ Final Client Script
🔹 Steps to Implement:
- Navigate to your ServiceNow instance.
- Go to "Client Scripts" (System Definition > Client Scripts).
- Create a new Client Script with:
- Type: onChange
- Table: Your target table (e.g., task_log)
- Field: Your radio button field (radio_button_field)
- Script: Copy & paste the above script.
- Save & Test 🚀
🔹 How It Works:
✔ When "Start" is selected, the Start Time field is updated.
✔ When "Completed" is selected, the Completion Time field is updated.
✔ The timestamp remains unchanged even if modifications occur later.
This way, you get a reliable time log for task completion without relying on "modified" timestamps.