Flow designer - approval request is sent to departments VP or Vice President

Wyatt Fudal1
Tera Guru

Hello, 

 

I am trying to create a flow where the approval request is sent to users Vice President. I tried using the dot walking for manager manager but the the companies organizational chart is not that clear. 

I tried scripting but I'm not the best at it. 

 

My script

answer = [];
var userTitle=gs.getProperty("user_title_for_approval");
var gr = new GlideRecord("sys_user");
gr.addQuery("Vice President", "CONTIANS", userTitle);
gr.query();
while (gr.next()) {
    answer.push(gr.getUniqueValue());
}
4 REPLIES 4

Hemanth M
Tera Sage

Hi @Wyatt Fudal1 ,

 

its expecting a string like this, if you look at your first screenshot

try this:

answer = [];
var userTitle=gs.getProperty("user_title_for_approval");
var gr = new GlideRecord("sys_user");
gr.addQuery("Vice President", "CONTIANS", userTitle);
gr.query();
while (gr.next()) {
    answer.push(gr.getUniqueValue());
}
return 'ApprovesRejectsAllZ['+answer+']'  
//answer has array of VP sys_ids 
//it should format something like this
//ex:  return 'ApprovesRejectsAllZ[0a826bf03710200044e0bfc8bcbe5d7a,71826bf03710200044e0bfc8bcbe5d3b,etc....]'

 

HemanthM1_0-1723138455278.png

 

Hope this helps!!!

 

 

Hello Henanth,

I put the script in but I'm receiving this error 'There was an error executing the flow:Internal Server Error. Exception while executing request: null'

 

Hi @Wyatt Fudal1 ,

 

Can you share screeshots if its ok, did you try execute your script in the backend script just to make sure returnuing correct output.

 

 

Hello Hermanth,

 

I did not try to execute script in the background. Should I try if gs.hasTitle or gs.getUserTitile?

 

Thank you