crmTech/ May 3, 2018/ Cloud, CRM, Salesforce Marketing Cloud/ 0 comments

In Salesforce Marketing Cloud, most of the time we need to retrieve the Publication Lists associated to the Subscriber.

Please find below SSJS code snippet for same.

UI FORM SECTION

<!DOCTYPE html>
 <html>
 <title>Getting All the List associated to Subscriber Email Address</title>
 <body>
 <h2>Getting All the List associated to Subscriber EmailAddress</h2>
 <form action="URL OF PUBLISHED CLOUD PAGE" method="post">
 Enter Your Email Address Here:
 <input type="text" name="emailId" value="">
 <br>
 <input type="submit" value="Submit">
 </form>
 </body>
 </html>

PROCESSING PAGE SECTION :

<html>
 <title>Getting All the List associated to Subscriber Email Address</title>
 <body>
 <h2>Getting All the List associated to Subscriber EmailAddress</h2>
 <script runat=server>
 Platform.Load("Core","1");
 
 var emailId = Platform.Request.GetFormField('emailId');//This Value will come from UI Form
 var data = DataExtension.Init("SSJS_Preferences");
 var SubKey;
 
 //emailId = "test@test.com";//For Testing I have given manual email Id here.
 
 //Start : Getting Subscriber Key
 var subObj = Subscriber.Retrieve({Property:"EmailAddress",SimpleOperator:"equals",Value:emailId});
 for(i = 0 ; i<subObj.length; i++)
 {
 SubKey = subObj[i].SubscriberKey;
 }
 //End : Getting Subscriber Key
 
 var subObj = Subscriber.Init(SubKey);
 var listArray = subObj.Lists.Retrieve();
 Write(Stringify(listArray));
 </script>
 </body>
 </html>
Advertisements
Share this Post

About crmTech

Sharad is working from more than 11 years in IT industry. He has giving his technical services in CRM for telecom, automobile, retail, finance industry in Sales, Service and Marketing. He has primary skill in Siebel and Salesforce Marketing Cloud. Apart from this he has worked in Google Cloud, Wordpress blogging, SEO optimization, Short film making, mobile apps creation,logo design creation for his own interest.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.