- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2021 02:45 AM
Hello All,
I have one requirement in which I have to set default value Requested for,Location,Employee Id,and Department.
I set the default value of Requested for but not able to set remaining. I attached the screen short of both
Please let me know if any one have idea.
Thanks & Regards
Keval
Solved! Go to Solution.
- Labels:
-
Script Debugger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2021 03:03 AM
Hi,
I assume Location variable is referring to cmn_location table; so do this
javascript: gs.getUser().getLocation();
I assume Department variable is referring to cmn_department table; so do this
javascript: gs.getUser().getDepartmentID();
I assume Employee ID is string variable; so do this
javascript: gs.getUser().getRecord().getValue('employee_number');
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2021 04:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2021 05:33 AM
Hi,
Did you check that user i.e. System Administrator has employee ID and location populated in user record?
are your using this in global scope or scoped app?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 04:08 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2021 03:08 AM
Hello Keval
From what I can see, this can be solved with an onChange client script.
Create a new onChange client script that runs onChange on the requested_for field. Then create a client script with a getReference() to retrieve the fields of the requested_for variable.
g_form.getReference('requested_for', function(userData){
g_form.setValue('department', userData.department);
});
https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideFormAPI#r_GlideForm-GetReference_S_F?navFilter=getReference
Kind regards
Quinten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2021 04:14 AM
Hii Keval,
use javascript:gs.getUser().manager.name;
Marks as helpful or correct if it helps you.
Thanks,
Rupali Bondar