Auto populate not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have been tasked with creating a catalog item of which i have the following acceptance criteria
As a user, I need the following fields to display if "New User Account" is selected for "What is your account request?"
- (show the following fields from the user record);
- Employee Phone Number
- Employee Number
- Email
So if i select New User account from a drop down menu selection it should automatically populate those three fields with the Requested for user's information, i presume. Do i make them all display only reference fields, and auto populate based on the requested for value. ? This is assuming i create another custom variable called requested for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Approach
1) use 1 reference variable pointing to sys_user
2) 3 single line text variable
3) create onChange catalog client script on that variable and if value is New User Account then auto-populate logged in user in that reference variable using g_user.userID
4) 3 single line text variable can be auto populated with no scripting using auto populate feature, check below blog
Auto-populate a variable based on a reference type variable (Utah)
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Yes, that’s the right general approach. Use Requested for as a reference variable pointing to the User (sys_user) table, then make Employee Phone Number, Employee Number, and Email read-only/display-only variables that populate from the selected user’s record. You can use a Catalog Client Script (onChange of Requested for) to retrieve those values, and a UI Policy to make the three fields visible only when “New User Account” is selected. You generally shouldn’t create a separate custom Requested for variable if the catalog item already provides the standard Requested for field.
