Auto-populate CI's mangaer name in approval list for workflow.

saran raj
Tera Contributor

Hi,

I have a requirement to auto-populate the manager name of (Is owned by-field) of CI in cmdb_ci_win_server table in approval activity in workflow. I used the below script but did not work. Could someone please help me?

 

var ser = new GlideRecord("cmdb_ci_win_server");
ser.addQuery("sys_id",current.variables.serverList4);
 
ser.query();
if(ser.next())
{
answer.push(ser.cmdb_ci_win_server.u_is_owned_by.mangaer);
}

 

The filed value of manager which is dot walked from is owned by is in below screenshot.

saranraj_0-1691568327977.png

 How can I trigger approval of the manager name if the server in workflow approval activity?

 

Thanks!

2 ACCEPTED SOLUTIONS

Harish KM
Kilo Patron
Kilo Patron

hello there is a error in your script

var answer = []; //define array

var ser = new GlideRecord("cmdb_ci_win_server");
ser.addQuery("sys_id",current.variables.serverList4);

ser.query();
if(ser.next())
{
answer.push(ser.u_is_owned_by.manager); //replace to this

}

Regards
Harish

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@saran raj 

are you sure that group has manager and that manager is active, not locked out and has email field populated?

no need to query you can directly dot walk

Also you are using wrong field name it;s manager

use this

answer = [];
answer.push(current.variables.serverList4.u_is_owned_by.manager.toString());

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

4 REPLIES 4

Harish KM
Kilo Patron
Kilo Patron

hello there is a error in your script

var answer = []; //define array

var ser = new GlideRecord("cmdb_ci_win_server");
ser.addQuery("sys_id",current.variables.serverList4);

ser.query();
if(ser.next())
{
answer.push(ser.u_is_owned_by.manager); //replace to this

}

Regards
Harish

Hi @Harish KM 

I used the same script as you mentioned but approval user of infrastructure is supported by manager name is triggering but I want "Is owned by" manager name in the approval user. Could you please?

var answer = [];
var ser = new GlideRecord("cmdb_ci_win_server");
ser.addQuery("sys_id",current.variables.serverList4);
 
ser.query();
if(ser.next())
{
answer.push(ser.u_is_owned_by.manager);
}
 

The approval user is triggering the manager name of "infrastructure is supported by" manager name instead of "is owned by" manager name. 

Hi please check what value your getting here?

current.variables.serverList4 // is this sysid of record?

u_is_owned_by // is this the field name referenced to group table? then manager name will be returned since we are dot walking to group table and selecting manager field

Regards
Harish

Ankur Bawiskar
Tera Patron
Tera Patron

@saran raj 

are you sure that group has manager and that manager is active, not locked out and has email field populated?

no need to query you can directly dot walk

Also you are using wrong field name it;s manager

use this

answer = [];
answer.push(current.variables.serverList4.u_is_owned_by.manager.toString());

If my response helped please mark it correct and close the thread so that it benefits future readers.

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