Glide record HR profile table to fetch Employee number and Domain ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2021 08:57 AM
I need to auto populate Employee number and domain id of the logged in user once the Service is opened from the portal.
I am writing an onLoad function in catalog client script and glide recording the sn_hr_core_profile table. number is the unique field in HR Profile table. But I am receiving an undefined message at the alert i used alert(g_user.number);. Can you please suggest me what i m missing here.
function onLoad() {
var reqgr = new GlideRecord('sn_hr_core_profile');
reqgr.addQuery('sys_id', g_user.number);
alert(g_user.number);
reqgr.query();
while(reqgr.next())
{
g_form.setValue('us_domain_id', reqgr.u_domain_id);
g_form.setValue('employee_number', reqgr.employee_id);
}
}
Let me know if anything needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2021 11:46 PM
Hi,
your BR is on which table?
Also is this for record producer or service catalog?
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
‎03-08-2021 03:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2021 03:58 AM
Hi,
then does your logged in user have HR profile in HR Profile table?
If yes then does that record have those 2 fields populated?
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
‎03-08-2021 04:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2021 05:12 AM
Hi,
is this happening for admins or non-admins
what came in BR logs?
Are you using correct field name for us_domain_id?
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sn_hr_core_profile');
gr.addQuery('user', gs.getUserID());
gr.query();
if(gr.next()){
gs.info('Record found domain ID' + gr.u_domain_id);
gs.info('Record found Employee number' + gr.employee_id);
current.us_domain_id = gr.u_domain_id;
current.employee_number = gr.employee_id;
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
