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

Hi,

Please inform them that this is not best practice and is not recommended

If they wish to enter employee ID manually and want other fields to be auto-populated then it makes no sense in keeping that field as dot walked and it should be standalone field

Regards
Ankur

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

Hi @Ankur Bawiskar 

Basically we have a Record producer which is having fields like-

find_real_file.png

 

These values we are storing in custom (sn_hr_core_id) table. This table data we manually need to send in workday and from workday we need to upload data in servicenow. So workday has provided all fields value but not employee name as employee can be multiple. So they provided Employee id and other custom field value that filled from portal variables.

So I need help how can I load data using transform map. I did mapping but when run transform map, it employee id did not map to employee number hence all below information is empty:

find_real_file.png

 

Can you please suggest? 

 

how is your mapping is done?

Why are you setting the dot walked field in field map?

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

This is how I did mapping-

find_real_file.png

 

I mapping dot walked field cz client has given employee id not employee name.

I doubt if it would work for dot walked field since value of it is derived from the parent field

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