How to Add Email from User Input Field to Notifications

symonflores_23
Tera Guru

Context: We created a catalog item with a user input field. We want to send an email notification to the email address entered by the user. Initially, we considered adding the entered email to the watchlist, since the watchlist can already be selected for notifications.

 

Do you have any other ideas for this? If using the watchlist is acceptable, how do we add the entered email variable to the watchlist?

 

symonflores_23_0-1716258463141.png

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@symonflores_23 

you cannot add the email directly.

you can use the workaround to populate the watch list field

you can use after insert BR on RITM with this script and condition

current.cat_item.name == 'Your Catalog Item Name Here'

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.watch_list = current.variables.variableName;
	current.setWorkflow(false);
	current.update();

})(current, previous);

If you are using workflow then have run script and have this script

	current.watch_list = current.variables.variableName;

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

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@symonflores_23 

you cannot add the email directly.

you can use the workaround to populate the watch list field

you can use after insert BR on RITM with this script and condition

current.cat_item.name == 'Your Catalog Item Name Here'

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.watch_list = current.variables.variableName;
	current.setWorkflow(false);
	current.update();

})(current, previous);

If you are using workflow then have run script and have this script

	current.watch_list = current.variables.variableName;

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

Thanks Ankur!