making document id type of field auto populated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2025 12:29 AM
Hello everyone, I have a question regarding field auto-population in ServiceNow. I'm working with the task_time_worked table and looking to implement the following behavior:
Goal: Auto-populate a "Document ID"-type of field when creating a new record.
Trigger: When a user clicks the New button to add a time worked entry.
Expected Functionality:
The TABLE and NON TASK fields should be auto-fill, depending on the context or source record from which the user initiated the time entry for example in PRB table, or Vulnerable item table
Has anyone implemented a similar use case in ServiceNow? I’d appreciate any guidance on best practices, scripts (e.g., in a client script or UI policy), or configuration recommendations.
Below is the screenshot of the form in time worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2025 12:41 AM
Hi @lhieanne ,
In order to populate these values you can use the following script in the business rule:
var tw = new GlideRecord('task_time_worked');
tw.initialize();
//other fields population
tw.u_target_table = current.getTableName();
tw.u_non_task = current.sys_id.toString();
//Other script lines. like tw.insert() or tw.update(); based on your requirement.
You can also refer to : https://www.servicenow.com/community/developer-forum/what-is-document-id-field-type-how-to-set-a-val...
Please mark the answer helpful and correct if it resolves the issue. Happy scripting
-Shantanu