Populate Employee details based on Employee id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2022 11:12 PM
Hi All,
I have a custom table. In which I have created a field called Employee name which is referring to sys_user table and from user table I have called other fields using dot walk as Employee Number, Country, LOcation which is auto populating from user profile
But now client want user should enter employee id then other fields should be auto populated. I have written below BR on that custom table (sn_hr_core_id):
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("sys_user");
gr.addQuery('employee_number' , current.u_employee_name.employee_number);
gr.query();
while(gr.next()){
gs.addInfoMessage("1");
current.u_employee_name = gr.name.toString();
current.update();
}
})(current, previous);
but not working. Any suggestion please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2022 11:20 PM
Hi,
then is that employee ID field a dot walked field or normal string field?
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-11-2022 11:22 PM
Hi
Employee Id means Employee number as shown in screenshot and yes it is dot walk field from user table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2022 11:26 PM
Hi,
If it's dot walked field then why do they wish to enter there as system would auto populate it based on selected user
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-11-2022 11:31 PM
Actually they have some data from workday and they provided a spreadsheet. In that sheet they given Employee Id and Employee name also but want to map employee id with employee number in servicenow as Employee name can be duplicate but employee id would be unique