Last active
November 26, 2018 16:38
-
-
Save jacebenson/0aa04023d3a28cd3b0d673d009ec199f to your computer and use it in GitHub Desktop.
Verify Unsubscribe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
${mail_script:unsubscribe_emails} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//name this unsubscribe_emails | |
(function runMailScript(current, template, email, email_action, event) { | |
var link = ''; | |
link += '<a href="' + gs.getProperty('glide.servlet.uri'); | |
//link += 'unsubscribe.do?sysparm_notification=' + email_action.sys_id; | |
link += 'verify_unsubscribe.do?notification=' + email_action.sys_id; | |
link += '">Unsubscribe from this email.</a><br />\n'; | |
//can this be unsubscribed from? | |
var notification = new GlideRecord('sysevent_email_action'); | |
notification.addQuery('active=true^sys_id=' + email_action.sys_id); | |
notification.addQuery('mandatory=false'); //this controls when someone can unsubscribe | |
notification.query(); | |
if (notification.next()) { | |
template.print(link); | |
} | |
})(current, template, email, email_action, event); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Name: verify_unsubscribe--> | |
<?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 type = false; | |
var notificationGR = new GlideRecord('sysevent_email_action'); | |
if(notificationGR.get(RP.getParameterValue('notification'))){ | |
type = notificationGR.getValue('name'); | |
} | |
</g:evaluate> | |
<j:if test="${type!=false}"> | |
<form> | |
<h1>Are you sure you want to unsubscribe from this type of notification?</h1> | |
<p>By clicking "Unsubscribe" you will no longer receive any notifications for "${type}".</p> | |
<a href="unsubscribe.do?sysparm_notification=${RP.getParameterValue('notification')}" class="btn btn-primary"> | |
Unsubscribe | |
</a> | |
</form> | |
</j:if> | |
<j:if test="${type==false}"> | |
<h1>Oops there was an error.</h1> | |
</j:if> | |
</j:jelly> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment