1

I am working on a custom profile center and I'm using server side javascript to extract information about the lists a subscriber is currently subscribed to. When I use the lists.retrieve function it successfully pulls out all the lists that a subscriber is on except for the All Subscriber list. I am working on an enterprise 2.0 account and I'm operating in one of the business units and our settings are established so that when a subscriber unsubscribes from all communications they unsubscribe from only the business unit.

What I need is a way to retrieve a subscriber's status on the All Subscribers List so I can accurately portray their status on my profile center.
I can do this with either SSJS or AmpScript if anyone knows a method in one language or the other.

Thanks, Jake

2 Answers 2

5

These days you can use the WSProxy to achieve what you need here. Run at parent level BU.

<script  runat="server">
Platform.Load("core","1.1.1");
var prox = new Script.Util.WSProxy();
var id = '1234abc'; //subscriber key
var queryAllAccounts = true; // this is important otherwise you just get the parent BU
var cols = ["Status","Client.ID"];
var filter = {
    Property: "SubscriberKey",
    SimpleOperator: "equals",
    Value: id
};
var desc = prox.retrieve("Subscriber", cols, filter, queryAllAccounts);
// desc.Results will be an array of... results.
</script>
1
  • 1
    This is the first time I've come across this WSProxy - you're a lifesaver! I'm dealing with 38x Business Units and needed to obtain the PublicationList Names in each one! Jun 10, 2019 at 0:34
3

Because its an Enterprise 2.0 account, you can do the following, using the subscriber system view (see more info at Data View: Subscribers):

%%[
    var @name       
    SET @name = "[email protected]"

    SET @status= Lookup("_subscribers", "status" , "EmailAddress", @name)

]%%

----- New EXAMPLE-----

Something I have using AMPscript in a clients code... may be useful here

        SET @rr2 = CreateObject("RetrieveRequest")
        SetObjectProperty(@rr2,"ObjectType","Subscriber")
        AddObjectArrayItem(@rr2, "Properties", "ID")
        AddObjectArrayItem(@rr2, "Properties", "EmailAddress")
        AddObjectArrayItem(@rr2, "Properties", "SubscriberKey")
        AddObjectArrayItem(@rr2, "Properties", "Status")

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

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

Then I loop through the results

8
  • Thanks for the answer but this isn't working for me. I have it on my landing page and it isn't returning a value for me. I'm also confused about the link you provided. You sent over the query activity data view but you are using ampscript. Can you use ampscript functions with the query data views? May 14, 2014 at 19:20
  • The link was for the purpose of showing the data views exposed, nothing more. You cannot use ampscript with query activities, although that would be interesting for sure. You may also try the SSJS found here (help.exacttarget.com/en/documentation/exacttarget/content/… scroll to Retrieving Lists from an Account) Can you post your exact code?
    – Timothy
    May 14, 2014 at 19:29
  • %%[ set @status = Lookup("_Subscribers", "Status" , "EmailAddress", "[email protected]") ]%% May 14, 2014 at 20:04
  • %%[ set @sk = [_subscriberkey] ]%% <script runat=server> Platform.Load("core","1"); var sk = Variable.GetValue("@sk"); var subObj = Subscriber.Init(sk); var attributes = subObj.Lists.Retrieve(); var attributesLength = attributes.length; Write(Stringify(attributes)); for (var i = 0; i < attributesLength; i++) { var listid = attributes[i].List.ID; if (listid == "17522427") { var status = attributes[i].Status; Variable.SetValue("kicksub",status); } else { } } </script> May 14, 2014 at 20:04
  • Ok I posted my attempt at what you sent me and then I posted the javascript I was trying to utilize. The listid in the javascript is the all subscribers listid for the business unit but as I said that isn't a recognized list when I execute this function. May 14, 2014 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .