The CreatorCon Call for Content is officially open! Get started here.

Catalog List Collector with Email

sgmartin
Kilo Guru

I've been looking all over and from what I see this is not possible in Service Catalog.

This is available on the Watcher field in Incident/Change:

find_real_file.png

From what I'm finding, this is not available on a List Collector variable in Service Catalog.  If so, has anyone come up with a suitable work-around?  I have found that after the Catalog Item has been submitted, the user can open the Requested Item and add emails to the Watchlist.  Users are lazy sometimes and don't want to have to go back and add later.

 

1 ACCEPTED SOLUTION

Would a single-line text field with a regex to validate email formatting work to accomplish this until the functionality becomes available as a SCI variable?

View solution in original post

7 REPLIES 7

Michael Jones -
Giga Sage

Unfortunately you are stuck with the display value on the table when using a list collector in a catalog item.

That being said...it's not perfect but...

 

*Warning - somewhat convoluted solution*

 

You could use a Multi-Row Variable Set, let's say name it email_list. Add a single variable to the MRVS, let's name it email, type lookup select box, lookup from table sys_user, lookup value field Email, and set a variable attribute of is_searchable_choice. 

That last part makes the select-box searchable. 

You end up with something like this: 

find_real_file.png

find_real_file.png

The value will be a JSON object with the values selected.

You can create a business rule and reference the value via current.variables.email_list

The result would be something like: 

[ {
  "email" : "abraham.lincoln@example.com"
}, {
  "email" : "admin@example.com"
}, {
  "email" : "adela.cervantsz@example.com"
} ]

 

You could then make a Business Rule, take the result, parse the object, extract the e-mail addresses, query the sys_user table, pull back the ID's and populate the watch list.

Note: I'm not sure if this was just happening to me in my PDI or if this would be an issue for you as well, but in a before / insert rule current.variables.email_list returned an empty object []. The same line in a background script worked like a charm, so I can only guess there's some delay in the values being populated so - as a work around, I added a multiline text field, hidden, that I populate with the MRVS value on submit via a catalog client-script. 

I named the hidden field object_string and used the following onsubmit: 

function onSubmit() {
   //Type appropriate comment here, and begin script below
   g_form.setValue('object_string', g_form.getValue('email_list'));
}

Then, in a business rule, advanced, before, on insert: 

(function executeRule(current, previous /*null when async*/) {
	
	var emailArr = [];
	var userArr = [];
	var obj = JSON.parse(current.variables.object_string);
	
	for(var i = 0; i < obj.length; i++) {
		emailArr.push(obj[i].email);
	}
	
	var user = new GlideRecord('sys_user');
	user.addEncodedQuery('emailIN' + emailArr);
	user.query();
	while(user.next()) {
		userArr.push(user.getValue('sys_id'));
	}
	
	current.watch_list = userArr;
	
	
})(current, previous);

 

That worked for me...

find_real_file.png

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

sgmartin
Kilo Guru

The point of all of it was to be able to input ad-hoc email addresses that aren't in ServiceNow.  For instance, a Distribution List (DL).  Granted, they still would need to know the actual email address of the DL, but they would be able to add it.

I'm going to move forward with a separate text field that users can add the email addresses comma separated.  I'll then extract those into an array and validate each one.  If one if invalid, they're all invalid.  Hopefully in versions to come, this will be an option in Service Catalog on a variable.

Thanks for all the responses.  

apurva3
Tera Expert

Hi ,

I have same requirement on catalog item

"NEED TO ADD MULTIPLE EMAIL ADDRESS AND SEND THE EMAIL USING WORKFLOW ACTIVITY"

can you please help me in this how can I get this, as  the list collector field  not allow to add email address , what can i do to collect the multiple email address and sent the notification to them.