How to auto populate the logged in user details using onload client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2022 01:43 AM
Hi All,
I have a requirement where I have created multiple variables - RequestedFor, RequestedBy, Location, City, Country, MobileNumber, ManagerName and incidentLists
1.user opens the form above details auto populate with logged in user
2.on change of user, above details to be changed auto change based on the user change
3.incidenlists var only be visible on the form once the all the user details entered
4.populate all the list of incidents raised by selcted user - reqfor
Please help me to achieve this requirement
Thanks&Regards,
Sweety.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2022 02:02 AM
Hi ,
Please write the on change client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gr = g_form.getReference('Requested_For',callBack);//update your variable name.
}
function callBack(gr){
g_form.setValue('Manager',gr.manager);
g_form.setValue('Location',gr.location);
g_form.setValue('Division',gr.department);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2022 02:14 AM
Thanks for the response.
Can you please provide me the onload script for auto populating the current logged in user details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2022 02:16 AM
Hey Sweety,
This will work onload as well as onchange also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2022 02:35 AM
Hi,
if you wish to auto-populate when form loads then is it based on logged in user's location, city, country?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader