[SalesForce] Retrieve subscriber status from a business unit with ampscript

I want to get the business unit level subscriber status of a subscriber from a landing page within that business unit. My first thought was a retrieve request on the subscriber by subscriber key but I came to understand that only retrieves the subscriber info from the enterprise business unit.

Now I am trying to use the listsubscriber retrieverequest and get the status of the subscriber by the list ID of the all subscribers list in that business unit. While it works on lists within that business unit, it does not recognized the all subscribers list. Here is my code.

 Set @retrieveReq= CreateObject("RetrieveRequest")
        SetObjectProperty(@retrieveReq,"ObjectType","ListSubscriber")
        AddObjectArrayItem(@retrieveReq,"Properties","SubscriberKey")
        AddObjectArrayItem(@retrieveReq,"Properties","ListID")
         AddObjectArrayItem(@retrieveReq,"Properties","Status")

    Set @sf1 = CreateObject("SimpleFilterPart")
        SetObjectProperty(@sf1,"Property","SubscriberKey")
        SetObjectProperty(@sf1,"SimpleOperator","equals")
        AddObjectArrayItem(@sf1,"Value",FIELD(@row,"SUBSCRIBER KEY")) 

    SetObjectProperty(@retrieveReq,"Filter",@sf1)

    SET @srows = InvokeRetrieve(@retrieveReq, @status)
        IF RowCount(@srows) > 0 THEN
        FOR @j = 1 to RowCount(@srows) DO
          SET @srow = row(@srows,@j)
          SET @listID = FIELD(@srow, "ListID")
           IF @listID == "176" THEN 
            SET @subStatus = Concat(@subStatus,@listID,FIELD(@srow, "Status"))  
           ENDIF      
        NEXT @j
    ENDIF

Where 176 is the list id of my business unit. Is this some kind of permissions issue within the business unit. I have used very similar code from landing pages in a parent business unit to get listsubscribers on child business units. this is the first time I've tried from within that business unit.

Thanks
wck

Best Answer

I have found a work around for this.

Basically if you can put your retrieve request in your parent business unit and pass the parameters using the CloudPagesURL(ID, 'SubscriberKey', _subscriberkey, 'Email', emailaddr, 'CustomField', '') to the secondary page in the child Business unit to Request the parameters from the parent BU using the RequestParameter function - you should be able to request the subscriber status.

Related Topic