5

ExactTarget is core edition. There are no Data Extensions, so we use Lists.

Am using landing page and trying to retrieve all the subscribers attributes of the List from SSJS and AMPScript but failed to get all. I get only Status, SubsciberKey, EmailAddress, CreatedDate. In SSJS , I get remaining attributes as undefined. Even I can only make filter query with these attributes only . For example i cant make like Source equals elead or sth..

SSJS:

<script runat="server" language="javascript">

Platform.Load("Core","1");
var myList = List.Init('list external key');
var subs = myList.Subscribers.Retrieve({Property:"Status", SimpleOperator:"equals", Value:"Active"});
var count =subs.length;

for (var i = 0; i < subs.length; i++) {

    Write("<tr>");
    Write("<td>" + i+ "</td>");
    Write("<td>" + subs[i].Status+ "</td>");
    Write("<td>" + subs[i].FirstName + "</td>");
    Write("<td>" + subs[i].LastName + "</td>");
    Write("<td>" + subs[i].FullName + "</td>");
    Write("<td>" + subs[i].SubscriberKey + "</td>");
    Write("<td>" + subs[i].EmailAddress + "</td>");
    Write("<td>" + subs[i].Region + "</td>");
    Write("<td>" + subs[i].CreatedDate + "</td>");
    Write("<td>" + subs[i].DateModified + "</td>");
    Write("<td>" + subs[i].Company + "</td>");
    Write("<td>" + subs[i].Mobile + "</td>");
    Write("<td>" + subs[i].OptIn + "</td>");
    Write("<td>" + subs[i].Source + "</td>");
    Write("</tr>");

}
</script>

AMPScript :

%%[

SET @rr2 = CreateObject("RetrieveRequest")
SetObjectProperty(@rr2,"ObjectType","Subscriber")

AddObjectArrayItem(@rr2, "Properties", "EmailAddress")
AddObjectArrayItem(@rr2, "Properties", "SubscriberKey")
AddObjectArrayItem(@rr2, "Properties", "Status")
AddObjectArrayItem(@rr2, "Properties", "Source")
AddObjectArrayItem(@rr2, "Properties", "CreatedDate")
AddObjectArrayItem(@rr2, "Properties", "ModifiedDate")

/* Create a filter be the subscriber Id */
SET @sfp2 = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp2,"Property","Status")
SetObjectProperty(@sfp2,"SimpleOperator","equals")
AddObjectArrayItem(@sfp2,"Value","Active")

/* invoke the Retrieve Call */
SetObjectProperty(@rr2,"Filter",@sfp2)
SET @atts = InvokeRetrieve(@rr2,@status)

FOR @cnt = 1 to ROWCOUNT(@atts) DO
    SET @att= ROW(@atts, @cnt)
    set @status1 = FIELD(@att, "Status")
    set @subsciberkey =FIELD(@att, "SubscriberKey")
    set @email =FIELD(@att, "EmailAddress")
    set @src =FIELD(@att, "Source")
    set @createdt=FIELD(@att, "CreatedDate")
    set @moddate=FIELD(@att, "ModifiedDate")

]%%

<body>
    <table>
        <tr>
            <td>%%=v(@cnt)=%%</td><td>---</td>
            <td>%%=v(@status)=%%</td><td>---</td>
            <td>%%=v(@status1)=%%</td><td>---</td>
            <td>%%=v(@subsciberkey)=%%</td><td>---</td>
            <td>%%=v(@email)=%%</td><td>---</td>
            <td>%%=v(@src)=%%</td><td>---</td>
            <td>%%=v(@createdt)=%%</td><td>---</td>
            <td>%%=v(@moddate)=%%</td><td>---</td>
        </tr>
    </table>
</body>

%%[ NEXT @cnt ]%%

</html>
0

You would need to use the Retrieve method on the Attributes object for each of your subscribers in your list in a for loop.

var myList = List.Init(listExternalKey); 

    var subsArray = myList.Subscribers.Retrieve(); 
    var de = DataExtension.Init(deSourceName); 
    for(var i = 0;subsArray.length>i&&200>i; i++){ //retrieving 200 subscribers
        var subresult = Subscriber.Retrieve({Property:"SubscriberKey",SimpleOperator:"equals",Value:subsArray[i].SubscriberKey});
        var subObj = Subscriber.Init(subresult[0].SubscriberKey); 
        var subAttributes = subObj.Attributes.Retrieve(); 
        var subAttributeSubscriberKey = subresult[0].SubscriberKey; 
        var subAttributeEmailAddress = subresult[0].EmailAddress;
        var deAddResults = de.Rows.Add({
            SubscriberKey:subAttributeSubscriberKey,
            EmailAddress:subAttributeEmailAddress,
            AccountID:(subAttributes[1].Value),
            FirstName:(subAttributes[2].Value)
            [etc]
            }
        }
| improve this answer | |

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.