This blog explains about how to retrieve any requester associated director email Address.
Scenario : Need to assign a specific request to requester associated director for approval
- Below method recursively calls until it finds the 'Director' role for a specific user
var answer=[];
answer.push(findDirector(current.variables.u_requester.toString()));
//pass the sys_id of user
function findDirector(id){
var gr= new GlideRecord("sys_user");
gr.get(id);
if(gr.title.indexOf("Director")>-1){
return gr.getValue('sys_id');
}
else{
return
findDirector(gr.getValue("manager"));
}
}