1

I am trying to receive a specific subscriber from a list by using the email address as an identifier. After I have this subscriber I want to print out it's subscription status. So far I am still stuck with retrieving the actual subscriber.

My code:

<script runat="server" language="javascript">
Platform.Load("core","1");
var promotions = List.Init('Promotions - 382');

var subscriber = promotions.Subscribers.Retrieve({Property:"Email Address", SimpleOperator:"Equals", Value:"matthias.claes@forward.eu"});
var count = subscriber.length;
Write('the count is: '+count);  

</script>

Output:

"The count is 0." 

When putting "Status" as the property and changing the "Value" to Active it does return the correct amount of active subscribers.

The list looks as follows, you can see that the email address is in the list.

enter image description here

0

You want to filter on the "SubscriberKey" field instead, as this is the main identifier. Using "Email Address" (or "EmailAddress") will return an empty array as you've discovered.

<script runat="server" language="javascript">
    Platform.Load("core","1");
    var promotions = List.Init('Promotions - 382');
    var subscriber = promotions.Subscribers.Retrieve({Property:"SubscriberKey", 
        SimpleOperator:"Equals", Value:"matthias.claes@forward.eu"});
    var count = subscriber.length;
    Write('the count is: ' + count);
    if (count > 0) {
        Write('<br>the status is: ' + subscriber[0].Status);  
    }
</script>

List.Subscribers.Retrieve returns an array, even though it will return only 1 record. Using subscriber[0] gets the first (and only) record in that array and then you can access the object properties using dot notation.

It is required to pass the "External Key" of the List in the List.Init() function and not the List Name. This is found in the Properties tab of the List in the application GUI. You have done this, just highlighting it for other readers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.