Glide record HR profile table to fetch Employee number and Domain ID

Renu9
Tera Contributor

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. 

21 REPLIES 21

@Renu 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Renu 

Hope you are doing good.

Did my reply answer your question?

Would you mind marking the best matching answer as correct and helpful, to close this thread?

Thanks!
Ankur

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader