Approval by application owner set by application set on catalog item

wiganmichae
Tera Contributor

Hi,

I have a catlog item that I want a user to select an applicaiton from a list (cmdb_ci_appl) and based of that I want the approval to be a user set on the application.  In my workflow I've set the following approval user activity script but it's just skipping the item when testing.

 
var answer = [];


var application = new GlideRecord("cmdb_ci_appl");


application.addQuery("u_system_owner",current.variables.u_mw_application_name);


application.query();


if(application.next()){


    answer.push(application.u_system_owner);


}

 

1 ACCEPTED SOLUTION

Hi @wiganmichae 

Try this

answer = [current.variables.u_mw_application_name.u_system_owner]

or

 

answer = []

answer.push(current.variables.u_mw_application_name.u_system_owner)

 

OR

answer = []
var application = new GlideRecord("cmdb_ci_appl");

if(application.get(current.variables.u_mw_application_name)){

    answer.push(application.u_system_owner);

}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

4 REPLIES 4

Chaitanya ILCR
Kilo Patron

Hi @wiganmichae ,

 

is variable u_mw_application_name is a reference field referencing cmdb_ci_appl table?

 

if yes you just need one line

answer.push(current.variables.u_mw_application_name.u_system_owner)

or

var application = new GlideRecord("cmdb_ci_appl");

if(application.get(current.variables.u_mw_application_name)){

    answer.push(application.u_system_owner);

}

else

looks the addQuery that you have use needs to update "instead of "u_system_owner" use the actual field the variable is returning

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Yes the variable just references the application table with a restriction of only operational systems.

My script was picking a user but not the correct one.  I just tried both of the above as the scripts above and neither returned a user and the workflow shows an error.

The field it's looking at is just a reference field to sys_user table.

 

wiganmichae_0-1749002023202.png

 

Hi @wiganmichae 

Try this

answer = [current.variables.u_mw_application_name.u_system_owner]

or

 

answer = []

answer.push(current.variables.u_mw_application_name.u_system_owner)

 

OR

answer = []
var application = new GlideRecord("cmdb_ci_appl");

if(application.get(current.variables.u_mw_application_name)){

    answer.push(application.u_system_owner);

}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Ok first script just skips but the second seems to have worked as expected on first test. 

I will continue to test but looks good at this stage thanks.