The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I create a link in an email notification for assign to me?

chrisperry
Mega Sage

I am sending an email notification to a single user about an incident being assigned to their group.  In the email notification, I am looking to include a link that will allow the user to click on it and have the specified incident assigned to them.

I have read that I might be able to use Processors for this requirement, but I am not at all familiar with creating/using processors.  Any help is much appreciated!

 

Thanks,
Chris

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry
1 ACCEPTED SOLUTION

I got this to work on my PDI

HTML

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<g2:evaluate var="jvar_unwrapped_url" jelly="true">
		var currentUser = gs.getUserID();
		var incidentFromURL = RP.getParameterValue('incident');
		var link = '';
		var incident = new GlideRecord('incident');
		if(incident.get('number', incidentFromURL)) {
			incident.setValue('assigned_to', currentUser);
			incident.update();
			gs.addInfoMessage(incident.getDisplayValue() + ' has been updated.');
			//gs.sendRedirect(incident.getLink());
			link = incident.getLink();
		}
		link || 'incident.do?sysparm_query=number=' + incidentFromURL;
	</g2:evaluate>
  ${gs.getMessage("Redirecting to your the incident")}...
</j:jelly>

Client Script

document.location.href = "$[JS:jvar_unwrapped_url]";

 

Link to the page with a url like /i.do?incident=INC12345

View solution in original post

9 REPLIES 9

Jace Benson
Mega Sage

Might be easier to just use a generic UI page with a url param for the record number or sys_id, then in the server script, do an update to the record to the logged in user, then gs.redirect to the record itself.

Thanks for your response, Jace.  Could you be a little more specific? 

I also do not have a ton of experience with UI pages - how are you suggesting to implement that into the email notification, and what kind of setup are you recommending for the generic UI page?

 

Thanks so much,
Chris

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

Hi Jace,

I set up a UI page that is working to assign the specified incident to the logged in user and redirect to the incident when the 'OK' button is clicked in the HTML portion.

Do you know of a way where the processing script in the UI page could be executed without having to submit the UI page by clicking 'OK' from the HTML piece?  Essentially I just want the user to be able to click the link, and automatically assign them to the incident record and redirect to the record.  Here is what I have so far:

find_real_file.png

 

Thanks again for your help!

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

In the HTML you could just add a <g:evaluate>/* code to do the update here*/</g:evaluate> and that will execute when the page loads server side.  Meaning it will update the code;

So I'd try this;

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
  <g:evaluate>
    var user = gs.getUserID();
    var incidentFromURL = RP.getParameterValue('incident');
    var link = '';
    //expects url of /uipage.do?incident=INC12345
    var incident = new GlideRecord('incident');
    if(incident.get('number', incidentFromURL)){
        incident.setValue('assigned_to', user);
        incident.update();
        link = incident.getLink();
    }
    gs.redirect(link);
  </g:evaluate>
</j:jelly>

Then you'd just have to make your email follow the link with the proper parameter.