Service Catalog form List collector value attribute on "Description" in RITM form

Zubair Alam
Tera Contributor

All kinds of suggestions are welcome.

My requirement is to populate the "Description" field on RITM with the users email attribute, selected on a list collector variable on Catalog Item form. 

How can we achieve this?

The user attribute that we want on RITM is only the email address of the user selected from sys_user on list collector on catalog item form. 

 

So basically the end user will pick users in the list collector variable pointing to sys_user, and the email of picked users should show in the "Description" field of RITM.
I know this forum has many Einsteins of ServiceNow to help me out. Thanks. 🙂

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Zubair Alam 

 

You can do it in WorkFlow Script, or Flow Designer using inline script or a simple business rules.

 

Let me explain using BR for example. Create an Before - Insert Business Rule on Requested Items (sc_req_item) table. In the when to run section tab, set the filter condition tab like,

 

item ::: IS ::: <Your Catalog Item for which you want this functionality>

 

Then, in the Advanced tab paste the following script inside the business rule function.

 

var sel_users = current.variables.YOUR_LIST_COLLECTOT_VARIABLE_NAME;

var usrGr = new GlideRecord('sys_user');

usrGr.addEncodedQuery("sys_idIN" + sel_users);

usrGr.query();

var desc = "";

while(usrGr._next()){

   desc = desc + "\n" + usrGr.getValue('email');

}

current.description = desc;

 

 

Try this an let me know if it didn't work.

 

Please mark my answer helpful and accept as a solution if it helped 👍

Thanks,
Anvesh

View solution in original post

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @Zubair Alam 

 

You can do it in WorkFlow Script, or Flow Designer using inline script or a simple business rules.

 

Let me explain using BR for example. Create an Before - Insert Business Rule on Requested Items (sc_req_item) table. In the when to run section tab, set the filter condition tab like,

 

item ::: IS ::: <Your Catalog Item for which you want this functionality>

 

Then, in the Advanced tab paste the following script inside the business rule function.

 

var sel_users = current.variables.YOUR_LIST_COLLECTOT_VARIABLE_NAME;

var usrGr = new GlideRecord('sys_user');

usrGr.addEncodedQuery("sys_idIN" + sel_users);

usrGr.query();

var desc = "";

while(usrGr._next()){

   desc = desc + "\n" + usrGr.getValue('email');

}

current.description = desc;

 

 

Try this an let me know if it didn't work.

 

Please mark my answer helpful and accept as a solution if it helped 👍

Thanks,
Anvesh

Zubair Alam
Tera Contributor

Hi @AnveshKumar M 

Bravo!!!

Your solution worked like a charm. 

Thanks for all the help.