Populate Employee details based on Employee id

Rekha Tiwari
Kilo Guru

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

 find_real_file.png

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?

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

then is that employee ID field a dot walked field or normal string field?

Regards
Ankur

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

Hi @Ankur Bawiskar 

 

Employee Id means Employee number as shown in screenshot and yes it is dot walk field from user table

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

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

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