Auto-populate fields from sys_user in a custom application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
I am building a custom Onboarding Access Request application in ServiceNow.
I have a Reference field that points to the sys_user table. When a user selects a person's name, I want several fields to automatically populate with information from the selected user record, such as:
- Department
- Training completion date
What is the recommended approach to accomplish this?
- Should I use an onChange Client Script with g_form.getReference()?
- Should I use a UI Policy?
- Should I fix this when I move it to Service Catalog?
- Is there a way to accomplish this using a Dependent field, or are Dependent fields only intended for filtering available choices?
I'm looking for the best practice that follows ServiceNow development standards and performs well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
16m ago
Hello @gmacias ,
There are 2 ways to achieve this
1) onchange client script + glide ajax
2) as you suggested onchange client script + getReference method
onchange client script + glide ajax : this follows ServiceNow best practices because it retrieves only the required fields, offers better performance, and provides more control over security and business logic.
onchange client script + getReference method : it retrieves the entire record, so GlideAjax is generally preferred for better scalability.
If this helps you then mark it as helpful and accept as solution.
Regards,
Aditya