ENCRYPT THE DATA USING GIVEN KEY

Provided Encryption Key : }Xx]v”t%J’y-M.s$l>}.`Ae;3x9E[&p9

The key provided is actually the key that must be used. However, we have to transform it first before using it in Ampscript function. The first problem we have with the key is that it contains a combination of double and single quotes, which poses an issue with AMPScript. To correct this, we must break the key into parts and then concatenate the parts back together into a single variable as seen below:

set @keypart1=”}Xx]v”

set @keypart2=’”‘

set @keypart3=”t%J’y-M.s$l>}.`Ae;3x9E[&p9″

set @key=Concat(@keypart1,@keypart2,@keypart3)

Then, we must truncate the key to 24 characters as seen below:

set @trunckey=Substring(@key,1,24)

Next, we take the truncated string and Base64 encode it to remove any incompatible characters:

SET @base64key=Base64Encode(@trunckey)

Finally, we can use the @base64key variable as our key in the encoding function:

SET @encData=EncryptSymmetric(@email, “tripledes;mode=ecb;padding=pkcs7”, @null, @base64key, @null, @null, @null, @null)

SET @decData=DecryptSymmetric(@encData, “tripledes;mode=ecb;padding=pkcs7”, @null, @base64key, @null, @null, @null, @null)

Note that we’re using tripledes instead of des…this was new information received from the client.

Altogether, here’s a fully functioning example that encrypts and decrypts email address and displays the value of various variables:

%%[

set @email=[Email Address]

set @keypart1=”}Xx]v”

set @keypart2=’”‘

set @keypart3=”t%J’y-M.s$l>}.`Ae;3x9E[&p9″

set @key=Concat(@keypart1,@keypart2,@keypart3)

set @trunckey=Substring(@key,1,24)

SET @base64key=Base64Encode(@trunckey)

SET @encData=EncryptSymmetric(@email, “tripledes;mode=ecb;padding=pkcs7”, @null, @base64key, @null, @null, @null, @null)

SET @decData=DecryptSymmetric(@encData, “tripledes;mode=ecb;padding=pkcs7”, @null, @base64key, @null, @null, @null, @null)

]%%

The key is: %%=v(@key)=%%

The truncated key is: %%=v(@trunckey)=%%

The Base64 encoded key is: %%=v(@base64key)=%%

Encrypted String is: %%=v(@encData)=%%

Decrypted String is: %%=v(@decData)=%%

COUPONCODE CHANGE FOR PLUS_GAP

%%[

Set @abbrev=LookUpRows(“ENT.Friends_and_Family_Configuration”,”brand_abbrev”,@brand)

Set @promo=Field(row(@abbrev,1),”promo_code”)

Set @code=Field(row(@abbrev,1),”bar_code”)

Set @barcode=LookUp(“ENT.Employee_ID_NEW”,”bar_code”,”employee_id”,@empid)

Set @barcode1=LookUp(“ENT.Employee_ID_NEW”,”coupon_code”,”employee_id”,@empid)

]%%

%%[IF @promo==”Y” AND @code==”Y” then]%%

%%=Substring(@couponcode,1,1)=%% %%=Substring(@couponcode,2,1)=%% %%=Substring(@couponcode,3,1)=%% %%=Substring(@couponcode,4,1)=%% %%=Substring(@couponcode,5,1)=%% %%=Substring(@couponcode,6,1)=%% %%=Substring(@couponcode,7,1)=%% %%=Substring(@couponcode,8,1)=%% %%=Substring(@couponcode,9,1)=%% %%=Substring(@couponcode,10,1)=%% %%=Substring(@couponcode,11,1)=%% %%=Substring(@couponcode,12,1)=%%

%%[ENDIF]%%

Instead of the above code and creating a new DE EDP_Employee_Coupon_Bar_Codes, we can use the below code for all BU’s

%%[

Set @barcode=LookUp(“ENT.Employee_ID_NEW”,”bar_code”,”employee_id”,@empid,” brand_abbrev”, @brand)

Set @couponcode=LookUp(“ENT.Employee_ID_NEW”,” coupon_code “,”employee_id”,@empid,” brand_abbrev”, @brand)

IF NOT empty(@barcode) and not empty(@couponcode)

]%%

%%=Substring(@couponcode,1,1)=%% %%=Substring(@couponcode,2,1)=%% %%=Substring(@couponcode,3,1)=%% %%=Substring(@couponcode,4,1)=%% %%=Substring(@couponcode,5,1)=%% %%=Substring(@couponcode,6,1)=%% %%=Substring(@couponcode,7,1)=%% %%=Substring(@couponcode,8,1)=%% %%=Substring(@couponcode,9,1)=%% %%=Substring(@couponcode,10,1)=%% %%=Substring(@couponcode,11,1)=%% %%=Substring(@couponcode,12,1)=%%

%%[ELSEIF not empty(@barcode)]%%

%%[ELSEIF not empty(@couponcode)]%%

%%=Substring(@couponcode,1,1)=%% %%=Substring(@couponcode,2,1)=%% %%=Substring(@couponcode,3,1)=%% %%=Substring(@couponcode,4,1)=%% %%=Substring(@couponcode,5,1)=%% %%=Substring(@couponcode,6,1)=%% %%=Substring(@couponcode,7,1)=%% %%=Substring(@couponcode,8,1)=%% %%=Substring(@couponcode,9,1)=%% %%=Substring(@couponcode,10,1)=%% %%=Substring(@couponcode,11,1)=%% %%=Substring(@couponcode,12,1)=%%

%%[ENDIF]%%

ADDING DATE PICKER

Requirement: Inserting a calendar button, with today’s date highlighted and adding (MM/DD/YYYY) so that if dates are being entered the user knows the format.

/*Upload both the JavaScript and CSS files in portfolio and then call it in html as below*/

/*Calender.js*/

function positionInfo(object) {

var p_elm = object;

this.getElementLeft = getElementLeft;

function getElementLeft() {

var x = 0;

var elm;

if(typeof(p_elm) == “object”){

elm = p_elm;

} else {

elm = document.getElementById(p_elm);

}

while (elm != null) {

if(elm.style.position == ‘relative’) {

break;

}

else {

x += elm.offsetLeft;

elm = elm.offsetParent;

}

}

return parseInt(x);

}

this.getElementWidth = getElementWidth;

function getElementWidth(){

var elm;

if(typeof(p_elm) == “object”){

elm = p_elm;

} else {

elm = document.getElementById(p_elm);

}

return parseInt(elm.offsetWidth);

}

this.getElementRight = getElementRight;

function getElementRight(){

return getElementLeft(p_elm) + getElementWidth(p_elm);

}

this.getElementTop = getElementTop;

function getElementTop() {

var y = 0;

var elm;

if(typeof(p_elm) == “object”){

elm = p_elm;

} else {

elm = document.getElementById(p_elm);

}

while (elm != null) {

if(elm.style.position == ‘relative’) {

break;

}

else {

y+= elm.offsetTop;

elm = elm.offsetParent;

}

}

return parseInt(y);

}

this.getElementHeight = getElementHeight;

function getElementHeight(){

var elm;

if(typeof(p_elm) == “object”){

elm = p_elm;

} else {

elm = document.getElementById(p_elm);

}

return parseInt(elm.offsetHeight);

}

this.getElementBottom = getElementBottom;

function getElementBottom(){

return getElementTop(p_elm) + getElementHeight(p_elm);

}

}

function CalendarControl() {

var calendarId = ‘CalendarControl’;

var currentYear = 0;

var currentMonth = 0;

var currentDay = 0;

var selectedYear = 0;

var selectedMonth = 0;

var selectedDay = 0;

var months = [‘January’,’February’,’March’,’April’,’May’,’June’,’July’,’August’,’September’,’October’,’November’,’December’];

var dateField = null;

function getProperty(p_property){

var p_elm = calendarId;

var elm = null;

if(typeof(p_elm) == “object”){

elm = p_elm;

} else {

elm = document.getElementById(p_elm);

}

if (elm != null){

if(elm.style){

elm = elm.style;

if(elm[p_property]){

return elm[p_property];

} else {

return null;

}

} else {

return null;

}

}

}

function setElementProperty(p_property, p_value, p_elmId){

var p_elm = p_elmId;

var elm = null;

if(typeof(p_elm) == “object”){

elm = p_elm;

} else {

elm = document.getElementById(p_elm);

}

if((elm != null) && (elm.style != null)){

elm = elm.style;

elm[ p_property ] = p_value;

}

}

function setProperty(p_property, p_value) {

setElementProperty(p_property, p_value, calendarId);

}

function getDaysInMonth(year, month) {

return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];

}

function getDayOfWeek(year, month, day) {

var date = new Date(year,month-1,day)

return date.getDay();

}

this.clearDate = clearDate;

function clearDate() {

dateField.value = ”;

hide();

}

this.setDate = setDate;

function setDate(year, month, day) {

if (dateField) {

if (month < 10) {month = “0” + month;}

if (day 12) {

currentMonth = 1;

currentYear++;

} else if(currentMonth < 1) {

currentMonth = 12;

currentYear–;

}

calendar = document.getElementById(calendarId);

calendar.innerHTML = calendarDrawTable();

}

this.changeYear = changeYear;

function changeYear(change) {

currentYear += change;

currentDay = 0;

calendar = document.getElementById(calendarId);

calendar.innerHTML = calendarDrawTable();

}

function getCurrentYear() {

var year = new Date().getYear();

if(year < 1900) year += 1900;

return year;

}

function getCurrentMonth() {

return new Date().getMonth() + 1;

}

function getCurrentDay() {

return new Date().getDate();

}

function calendarDrawTable() {

var dayOfMonth = 1;

var validDay = 0;

var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);

var daysInMonth = getDaysInMonth(currentYear, currentMonth);

var css_class = null; //CSS class for each day

var table = “

”;

table = table + “

”;

table = table + ”

”;

table = table + ”

”;

table = table + ”

”;

table = table + “

”;

table = table + “

”;

for(var week=0; week < 6; week++) {

table = table + “

”;

for(var dayOfWeek=0; dayOfWeek daysInMonth) {

validDay = 0;

}

if(validDay) {

if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {

css_class = ‘current’;

} else if (dayOfWeek == 0 || dayOfWeek == 6) {

css_class = ‘weekend’;

} else {

css_class = ‘weekday’;

}

table = table + “

”;

dayOfMonth++;

} else {

table = table + “

”;

}

}

table = table + “

”;

}

table = table + “

”;

table = table + “

< « ” + months[currentMonth-1] + “
” + currentYear + “
» >
S M T W T F S
”+dayOfMonth+”  
Clear | Close

”;

return table;

}

this.show = show;

function show(field) {

can_hide = 0;

// If the calendar is visible and associated with

// this field do not do anything.

if (dateField == field) {

return;

} else {

dateField = field;

}

if(dateField) {

try {

var dateString = new String(dateField.value);

var dateParts = dateString.split(“/”);

selectedMonth = parseInt(dateParts[0],10);

selectedDay = parseInt(dateParts[1],10);

selectedYear = parseInt(dateParts[2],10);

} catch(e) {}

}

if (!(selectedYear && selectedMonth && selectedDay)) {

selectedMonth = getCurrentMonth();

selectedDay = getCurrentDay();

selectedYear = getCurrentYear();

}

currentMonth = selectedMonth;

currentDay = selectedDay;

currentYear = selectedYear;

if(document.getElementById){

calendar = document.getElementById(calendarId);

calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);

setProperty(‘display’, ‘block’);

var fieldPos = new positionInfo(dateField);

var calendarPos = new positionInfo(calendarId);

var x = fieldPos.getElementLeft();

var y = fieldPos.getElementBottom();

setProperty(‘left’, x + “px”);

setProperty(‘top’, y + “px”);

if (document.all) {

setElementProperty(‘display’, ‘block’, ‘CalendarControlIFrame’);

setElementProperty(‘left’, x + “px”, ‘CalendarControlIFrame’);

setElementProperty(‘top’, y + “px”, ‘CalendarControlIFrame’);

setElementProperty(‘width’, calendarPos.getElementWidth() + “px”, ‘CalendarControlIFrame’);

setElementProperty(‘height’, calendarPos.getElementHeight() + “px”, ‘CalendarControlIFrame’);

}

}

}

this.hide = hide;

function hide() {

if(dateField) {

setProperty(‘display’, ‘none’);

setElementProperty(‘display’, ‘none’, ‘CalendarControlIFrame’);

dateField = null;

}

}

this.visible = visible;

function visible() {

return dateField

}

this.can_hide = can_hide;

var can_hide = 0;

}

var calendarControl = new CalendarControl();

function showCalendarControl(textField) {

// textField.onblur = hideCalendarControl;

calendarControl.show(textField);

}

function clearCalendarControl() {

calendarControl.clearDate();

}

function hideCalendarControl() {

if (calendarControl.visible()) {

calendarControl.hide();

}

}

function setCalendarControlDate(year, month, day) {

calendarControl.setDate(year, month, day);

}

function changeCalendarControlYear(change) {

calendarControl.changeYear(change);

}

function changeCalendarControlMonth(change) {

calendarControl.changeMonth(change);

}

document.write(“”);

document.write(“

”);

——————————————————————————————————————————–

/* Calender.css*/

#CalendarControlIFrame { display: none; left: 0px; position: absolute; top: 0px; height: 250px; width: 250px; z-index: 99;} #CalendarControl { position:absolute; background-color:#FFF; margin:0; padding:0; display:none; z-index: 100;} #CalendarControl table { font-family: arial, verdana, helvetica, sans-serif; font-size: 8pt; border-left: 1px solid #336; border-right: 1px solid #336;} #CalendarControl th { font-weight: normal;} #CalendarControl th a { font-weight: normal; text-decoration: none; color: #FFF; padding: 1px;} #CalendarControl td { text-align: center;} #CalendarControl .header { background-color: #336;} #CalendarControl .weekday { background-color: #DDD; color: #000;} #CalendarControl .weekend { background-color: #FFC; color: #000;} #CalendarControl .current { border: 1px solid #339; background-color: #336; color: #FFF;} #CalendarControl .weekday,#CalendarControl .weekend,#CalendarControl .current { display: block; text-decoration: none; border: 1px solid #FFF; width: 2em;} #CalendarControl .weekday:hover,#CalendarControl .weekend:hover,#CalendarControl .current:hover { color: #FFF; background-color: #336; border: 1px solid #999;} #CalendarControl .previous { text-align: left;} #CalendarControl .next { text-align: right;} #CalendarControl .previous,#CalendarControl .next { padding: 1px 3px 1px 3px; font-size: 1.4em;} #CalendarControl .previous a,#CalendarControl .next a { color: #FFF; text-decoration: none; font-weight: bold;} #CalendarControl .title { text-align: center; font-weight: bold; color: #FFF;} #CalendarControl .empty { background-color: #CCC; border: 1px solid #FFF;}

——————————————————————————————————————————–

Check-In Date*

Check-Out Date*

SESSION IN JAVASCRIPT

What is Session?

The session state is used to maintain the session of each user throughout the application. Session allows information to be stored in one page and access in another page and support any type of object. In many websites we will see the functionality like once if we login into website they will show username in all the pages for that they will store username in session and they will access that session username in all the pages.

Whenever user enters into website new session id will generate for that user. This session Id will delete when he leave from that application. If he enters again he will get new session Id.

How to declare Session in JavaScript?

Set value into the session object = sessionStorage.setItem(String key, String Data);

Get session value = sessionStorage.getItem(String key);

Example:

We can check this with simple example for creating login page and passing session value in Main.html page if the session value is empty user will redirect to login page.

Login.html

sessionStorage.setItem(‘Login’, ‘true’);

Main.html

var session = sessionStorage.getItem(‘Login’);// Need to pass same string key variable

if (session == ” || session == null)

window.location = ‘login.html’;

else

alert(session); // if the session value store successfully it will return true

FIND THE FOLDER ID DYNAMICALLY IN ET APPLICATION

/* To find the any folder ID dynamically using SSJS
Value:XXXXX –> Need to pass respective entity type.
Entity & Type details are available in the below path.
https://help.exacttarget.com/en/technical_library/web_service_guide/objects/datafolder/
*/

Platform.Load(“core”,”1″);
var deDetails = Folder.Retrieve({Property:”ContentType”,SimpleOperator:”equals”,Value:”media”});
for(var i=0; deDetails.length>i; i++){
Write(‘Name:-‘+deDetails[i].Name+’ ‘+’Id:-‘+deDetails[i].ID+’
’)
}

FIND THE PUBLICATION LIST ID

/* By using AmpScript to find the Publication List ID Dynamically */

%%[
Set @MID = XXXXXX
IF Not Empty(@MID) Then
Set @clientID = CreateObject(“ClientID”)
SetObjectProperty(@clientID, “ID”,@MID)
SET @retrieveRequest = CreateObject(“RetrieveRequest”)
SetObjectProperty(@retrieveRequest, “ObjectType”, “List”)
AddObjectArrayItem(@retrieveRequest, “ClientIDs”, @clientID)

SET @simpleFilterPart = CreateObject(“SimpleFilterPart”)
SetObjectProperty(@simpleFilterPart, “Property”, “ListClassification”)
SetObjectProperty(@simpleFilterPart, “SimpleOperator”, “equals”)
AddObjectArrayItem(@simpleFilterPart, “Value”, “PublicationList”)

AddObjectArrayItem(@retrieveRequest,”Properties”,”ListName”)
AddObjectArrayItem(@retrieveRequest,”Properties”,”ID”)

SetObjectProperty(@retrieveRequest, “Filter”, @simpleFilterPart)
SET @ls = InvokeRetrieve(@retrieveRequest,@status,@reqID)
EndIf

]%%
%%[
IF RowCount(@ls) > 0 THEN
FOR @i = 1 TO RowCount(@ls) DO
SET @row = Row(@ls,@i)
SET @id = Field(@row,”ID”)
SET @listName = Field(@row,”ListName”)
SET @Description = Field(@row,”Description”)

]%%
%%=v(@id)=%%%%=v(@listName )=%%
%%[
Next @i
Endif
]%%

PREFERENCE CENTER USING BASIC SSJS

/* Preference Center values Retrieve,Display, Add, Update and Subscribe or Unsubscribe by using SSJS */

Platform.Load(“core”,”1″);

var email = Request.GetQueryStringParameter(“e”);
Variable.SetValue(“email”,email);
var data = DataExtension.Init(“SSJS_Preferences”);
var subscriberData = data.Rows.Lookup([“EmailAddress”], [email]);

for(var i=0; subscriberData.length>i; i++)
{
Variable.SetValue(“EmailAddress”,subscriberData[i][‘EmailAddress’]);
Variable.SetValue(“Newsletter”,subscriberData[i][‘Newsletter’]);
Variable.SetValue(“UpcomingCourses”,subscriberData[i][‘UpcomingCourses’]);
Variable.SetValue(“SeminarSpecials”,subscriberData[i][‘SeminarSpecials’]);
Variable.SetValue(“Product”,subscriberData[i][‘Product’]);
Variable.SetValue(“UnSubscribeAll”,subscriberData[i][‘UnSubscribeAll’]);
}

if(subscriberData.length>0)
{
Variable.SetValue(“Action”,”Update”);
}
else
{
Variable.SetValue(“Action”,”Add”);
}
var subscriberStatus = Subscriber.Retrieve({Property:”EmailAddress”,SimpleOperator:”equals”,Value:email});
var SubscriberKey = subscriberStatus[0].SubscriberKey;
Variable.SetValue(“SubscriberKey”,SubscriberKey);

Subscriber Preferences

function UNSUBSCRIBEALL_onChange(box){
if(box.checked){
document.forms[0].NEWSLETTER.checked = false;
document.forms[0].UPCOMING.checked = false;
document.forms[0].SPECIALS.checked = false;
document.forms[0].PRODUCT.checked = false;
}
}

function option_onChange(box){
if(box.checked){
document.forms[0].UNSUBSCRIBEALL.checked = false;
}
if(document.getElementById(‘NEWSLETTER’).checked == false && document.getElementById(‘UPCOMING’).checked == false && document.getElementById(‘SPECIALS’).checked == false && document.getElementById(‘PRODUCT’).checked == false)
{
document.getElementById(‘UNSUBSCRIBEALL’).checked = true;
}
}

Email Address: %%=v(@email)=%%
Preferences Published Subscribe
eNewsletter Quarterly
Upcoming courses Weekly
Seminar specials Weekly
Audio conferences, Webinars and product offers Weekly
Please remove me from all e-mail correspondence.

/* Processing Page*/

Platform.Load(“core”,”1″);

try
{
var email = Request.GetFormField(“email”);
var NEWSLETTER = Request.GetFormField(“NEWSLETTER”);
var UPCOMING = Request.GetFormField(“UPCOMING”);
var SPECIALS = Request.GetFormField(“SPECIALS”);
var PRODUCT = Request.GetFormField(“PRODUCT”);
var UNSUBSCRIBEALL = Request.GetFormField(“UNSUBSCRIBEALL”);
var Action = Request.GetFormField(“Action”);
var SubscriberKey = Request.GetFormField(“SubscriberKey”);
var subObj,status;

if(NEWSLETTER == “on”){
NEWSLETTER = “True”;
}
else{
NEWSLETTER = “False”;
}

if(UPCOMING == “on”){
UPCOMING = “True”;
}
else{
UPCOMING = “False”;
}

if(SPECIALS == “on”){
SPECIALS = “True”;
}
else{
SPECIALS = “False”;
}

if(PRODUCT == “on”){
PRODUCT = “True”;
}
else{
PRODUCT = “False”;
}

if(UNSUBSCRIBEALL == “on”){
UNSUBSCRIBEALL = “True”;
subObj = Subscriber.Init(SubscriberKey);
status = subObj.Unsubscribe();
}
else{
UNSUBSCRIBEALL = “False”;
var newSubscriber = {
“EmailAddress”: email,
“SubscriberKey”: SubscriberKey,
“Status”: “Active”
};
subObj = Subscriber.Init(SubscriberKey);
status = subObj.Upsert(newSubscriber);;
}
var DE = DataExtension.Init(“SSJS_Preferences”);

if(Action == “Add”)
{
DE.Rows.Add(
{
EmailAddress: email,
Newsletter: NEWSLETTER,
UpcomingCourses: UPCOMING,
SeminarSpecials: SPECIALS,
Product: PRODUCT,
UnSubscribeAll: UNSUBSCRIBEALL
});
}
else
{
DE.Rows.Update(
{
Newsletter: NEWSLETTER, UpcomingCourses: UPCOMING, SeminarSpecials: SPECIALS, Product: PRODUCT,UnSubscribeAll: UNSUBSCRIBEALL
},
[“EmailAddress”],[email]
);
}
Write(“Thank You!!!”)
}
catch(e)
{
Write(e.message);
}

PREFERENCE CENTER USING BASIC SSJS

/* Preference Center values Retrieve,Display, Add, Update and Subscribe or Unsubscribe by using SSJS */

Platform.Load(“core”,”1″);

var email = Request.GetQueryStringParameter(“e”);
Variable.SetValue(“email”,email);
var data = DataExtension.Init(“SSJS_Preferences”);
var subscriberData = data.Rows.Lookup([“EmailAddress”], [email]);

for(var i=0; subscriberData.length>i; i++)
{
Variable.SetValue(“EmailAddress”,subscriberData[i][‘EmailAddress’]);
Variable.SetValue(“Newsletter”,subscriberData[i][‘Newsletter’]);
Variable.SetValue(“UpcomingCourses”,subscriberData[i][‘UpcomingCourses’]);
Variable.SetValue(“SeminarSpecials”,subscriberData[i][‘SeminarSpecials’]);
Variable.SetValue(“Product”,subscriberData[i][‘Product’]);
Variable.SetValue(“UnSubscribeAll”,subscriberData[i][‘UnSubscribeAll’]);
}

if(subscriberData.length>0)
{
Variable.SetValue(“Action”,”Update”);
}
else
{
Variable.SetValue(“Action”,”Add”);
}
var subscriberStatus = Subscriber.Retrieve({Property:”EmailAddress”,SimpleOperator:”equals”,Value:email});
var SubscriberKey = subscriberStatus[0].SubscriberKey;
Variable.SetValue(“SubscriberKey”,SubscriberKey);

Subscriber Preferences

function UNSUBSCRIBEALL_onChange(box){
if(box.checked){
document.forms[0].NEWSLETTER.checked = false;
document.forms[0].UPCOMING.checked = false;
document.forms[0].SPECIALS.checked = false;
document.forms[0].PRODUCT.checked = false;
}
}

function option_onChange(box){
if(box.checked){
document.forms[0].UNSUBSCRIBEALL.checked = false;
}
if(document.getElementById(‘NEWSLETTER’).checked == false && document.getElementById(‘UPCOMING’).checked == false && document.getElementById(‘SPECIALS’).checked == false && document.getElementById(‘PRODUCT’).checked == false)
{
document.getElementById(‘UNSUBSCRIBEALL’).checked = true;
}
}

Email Address: %%=v(@email)=%%
Preferences Published Subscribe
eNewsletter Quarterly
Upcoming courses Weekly
Seminar specials Weekly
Audio conferences, Webinars and product offers Weekly
Please remove me from all e-mail correspondence.

/* Processing Page*/

Platform.Load(“core”,”1″);

try
{
var email = Request.GetFormField(“email”);
var NEWSLETTER = Request.GetFormField(“NEWSLETTER”);
var UPCOMING = Request.GetFormField(“UPCOMING”);
var SPECIALS = Request.GetFormField(“SPECIALS”);
var PRODUCT = Request.GetFormField(“PRODUCT”);
var UNSUBSCRIBEALL = Request.GetFormField(“UNSUBSCRIBEALL”);
var Action = Request.GetFormField(“Action”);
var SubscriberKey = Request.GetFormField(“SubscriberKey”);
var subObj,status;

if(NEWSLETTER == “on”){
NEWSLETTER = “True”;
}
else{
NEWSLETTER = “False”;
}

if(UPCOMING == “on”){
UPCOMING = “True”;
}
else{
UPCOMING = “False”;
}

if(SPECIALS == “on”){
SPECIALS = “True”;
}
else{
SPECIALS = “False”;
}

if(PRODUCT == “on”){
PRODUCT = “True”;
}
else{
PRODUCT = “False”;
}

if(UNSUBSCRIBEALL == “on”){
UNSUBSCRIBEALL = “True”;
subObj = Subscriber.Init(SubscriberKey);
status = subObj.Unsubscribe();
}
else{
UNSUBSCRIBEALL = “False”;
var newSubscriber = {
“EmailAddress”: email,
“SubscriberKey”: SubscriberKey,
“Status”: “Active”
};
subObj = Subscriber.Init(SubscriberKey);
status = subObj.Upsert(newSubscriber);;
}
var DE = DataExtension.Init(“SSJS_Preferences”);

if(Action == “Add”)
{
DE.Rows.Add(
{
EmailAddress: email,
Newsletter: NEWSLETTER,
UpcomingCourses: UPCOMING,
SeminarSpecials: SPECIALS,
Product: PRODUCT,
UnSubscribeAll: UNSUBSCRIBEALL
});
}
else
{
DE.Rows.Update(
{
Newsletter: NEWSLETTER, UpcomingCourses: UPCOMING, SeminarSpecials: SPECIALS, Product: PRODUCT,UnSubscribeAll: UNSUBSCRIBEALL
},
[“EmailAddress”],[email]
);
}
Write(“Thank You!!!”)
}
catch(e)
{
Write(e.message);
}

RETRIEVE SUBSCRIBER ATTRIBUTES FROM ALLSUBSCRIBER LIST USING AMPSCRIPT

%%[
SET @EmailAddress = QueryParameter(“Em”)

If Not Empty(@EmailAddress) Then
SET @Retrive = CreateObject(“RetrieveRequest”)
SetObjectProperty(@Retrive, “ObjectType”, “Subscriber”)
AddObjectArrayItem(@Retrive, “Properties”, “ID”)
AddObjectArrayItem(@Retrive, “Properties”, “Status”)
AddObjectArrayItem(@Retrive, “Properties”, “SubscriberKey”)
AddObjectArrayItem(@Retrive,”Properties”,”EmailAddress”)

SET @SFP = CreateObject(“SimpleFilterPart”)
SetObjectProperty(@SFP,”Property”,”EmailAddress”)
SetObjectProperty(@SFP,”SimpleOperator”,”equals”)
AddObjectArrayItem(@SFP,”Value”,@EmailAddress)

SetObjectProperty(@Retrive, “Filter”, @SFP)
SET @IRetrieve = InvokeRetrieve(@Retrive,@status_rr,@reqID)

IF RowCount(@IRetrieve) > 0 THEN

Set @Email=Field(Row(@IRetrieve,1),”EmailAddress”)
SET @Status = Field(row(@IRetrieve,1),”Status”)
Set @Skey=Field(Row(@IRetrieve,1),”SubscriberKey”)
SET @subAtts = Field(Row(@IRetrieve,1),”Attributes”)
FOR @i = RowCount(@subAtts) DOWNTO 1 DO
SET @att = Row(@subAtts,@i)
SET @att_name = Field(@att,’Name’)
SET @att_val = Field(@att,’Value’)

IF @att_name == “First Name” THEN
SET @FirstName = @att_val
ELSEIF @att_name == “LName” THEN
SET @LastName = @att_val
ELSEIF @att_name == “LanguagePref” THEN
SET @LanguagePref = @att_val
ELSEIF @att_name == “HTML Emails” THEN
SET @HTMLEmails = @att_val
ELSEIF @att_name == “Language Preference” THEN
SET @LanguagePreference = @att_val
ENDIF

NEXT @i
ENDIF
EndIf
]%%

Blog at WordPress.com.

Up ↑