- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 10:13 AM
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sys_user');
gr.addQuery('employee_number',current.variable.manager_employee_number);
gr.query();
if(gr.next()){
{
current.variable.hiring_manager= current.gr.sys_id;
current.update();
}
}
})(current, previous);
Manager employee number is a string variable and I am trying to populate the hiring manager field. so This catalog item is getting generated from integration they are sending us the employee number and we have to populate the hiring manager from that number.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2023 11:37 AM
Thanks Hemanth for your reply.
I fixed my code and it's working now.
Here is the updated code.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sys_user');
gr.addQuery('employee_number',current.variables.manager_employee_number);
gs.info("Manager number "+" "+current.variables.manager_employee_number);
gr.query();
if(gr.next()){
{
current.variables.hiring_manager= gr.sys_id;
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 11:28 PM
Hi @Vdixt ,
Use variables instead variable
like :
addQueryline - current.variables.manager_employee_number
update line : current.variables.hiring_manager= current.gr.sys_id;
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2023 05:16 AM
Thanks Hemanth for your response.
but still the hiring manager field is still not populating.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2023 06:15 AM
Hi @Vdixt ,
When does this BR runs???, Need to understand your form variables.
check are you getting manager_employee_number by logging it BR.
gs.info("Manager number "+" "+current.variables.manager_employee_number)
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2023 06:29 AM
I checked it I am getting the manger employee number, so this request is creating through third party tool, we are using scripted rest API to set the variables, so now they are sending us the Manager employee number and we have to populate the hiring manager field after creating the request.