Approval needs to be trigger to hr partner who is existing in the users table

Servicenow de11
Tera Contributor

Hello,

 

I have a requirement that is in the catalog item workflow approval will trigger to hr parter(customized field) in the users table.

can any one help me how to achieve this.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Kavita_Bhojane
Tera Guru

Hi @Servicenow de11 ,

 

HR Partner field should be reference field. If not you need to first find out Requested For's manager’s HR partner name. Once you got the name you can look for user in User table with the Requested For's manager’s HR partner name. Once you got the user record you can use the sys_id of that user to get approval.

Please mark my answer helpful if you find it useful.

 

Thanks,

Kavita Bhojane

View solution in original post

7 REPLIES 7

Kavita_Bhojane
Tera Guru

Hi @Servicenow de11 ,

 

You can use Approval User activity in workflow as below:

 

answer = [];


var appr = new GlideRecord("sys_user");
appr.addQuery('sys_id', current.variables.requested_for); //Here I am considering you are looking for Requested For's HR partner's approval
appr.query();
if (appr.next()) {
answer.push(appr.hr_partner); //pass sys_id of HR Partner
}

Screenshot 2023-10-26 at 6.46.26 PM.png

 

Please mark my answer helpful if you find it useful.

 

Thanks,

Kavita Bhojane

Hi Kavita,

 

My apolizise wrongly entered in question 'Approval will trigger to 'Requested for' manager's hr partner'. And

in the script (answer.push(appr.hr_partner);) i need to pass sys_id of the hr partner field right?

Hi @Servicenow de11 ,

 

You can use below script:

 

var appr = new GlideRecord("sys_user");
appr.addQuery('sys_id', current.variables.requested_for.manager); //Requested For's manager’s HR partner approval
appr.query();
if (appr.next()) {
answer.push(appr.hr_partner); //pass sys_id of HR Partner
}

Please mark my answer helpful if you find it useful.

 

Thanks,

Kavita Bhojane

 

Hi Kavita,

 

Servicenowde11_0-1698564162108.png

 

Tried the script but no luck.

Hr partner field is the string field not a reference field in the user's table i think this is the reason for script not working.

Servicenowde11_1-1698563908579.png