0

I am looking to see if it is possible to grab the current status of a subscriber whether they are "active" or "unsubscribed" to a list. I am creating a custom profile center that grabs all the lists using SSJS and subscribes the clients to the lists using WebCollect.

I want to put another column that describes "Status" and whether they are active or unsubscribed within that particular list. Am I able to do this using SSJS or AMPscript? Or will it need to be used with some type of API call?

2 Answers 2

0

You can do this with Ampscript and the SOAP Web services.

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

    /* Creating a simple filter based on Subscriber Key*/
    SET @sfp = CreateObject("SimpleFilterPart")
    SetObjectProperty(@sfp,"Property","SubscriberKey")
    SetObjectProperty(@sfp,"SimpleOperator","equals")
    AddObjectArrayItem(@sfp,"Value",@email)

    /* Invoking the Retrieve Call */
    SetObjectProperty(@rr2,"Filter",@sfp)
    SET @substatus = InvokeRetrieve(@rr,@status)

You can then upsert the the retrieved status using the UpsertData Ampscript function.

3
  • What would @substatus equal to? Just whatever their current status is? Commented Jun 26, 2018 at 13:17
  • yes @Shuckyducky. It would be whatever their status is
    – 0xsegfault
    Commented Jun 26, 2018 at 21:42
  • Is there a way about doing this in SSJS? The AMPscript doesn't seem to be functioning correctly @Data_Kid Commented Jun 27, 2018 at 16:10
0

Here's the fixed code for whoever needs to retrieve the Subscriber Status from All Subscribers with AMPscript:

%%[

  VAR @rr, @sfp, @requestStatus, @requestId, @allSubRows, @allSubRow, @subStatus

  /* Creating the RetrieveRequest object with the SubscriberKey and Status as properties */
  SET @rr = CreateObject('RetrieveRequest')
  SetObjectProperty(@rr,'ObjectType','Subscriber')
  AddObjectArrayItem(@rr, 'Properties', 'SubscriberKey')
  AddObjectArrayItem(@rr, 'Properties', 'Status')

  /* Creating a simple filter based on SubscriberKey for the RetrieveRequest object */
  SET @sfp = CreateObject('SimpleFilterPart')
  SetObjectProperty(@sfp,'Property','SubscriberKey')
  SetObjectProperty(@sfp,'SimpleOperator','equals')
  AddObjectArrayItem(@sfp,'Value', @subscriberKey)
  SetObjectProperty(@rr,'Filter', @sfp)

  /* Invoking the Retrieve Call */
  SET @allSubRows = InvokeRetrieve(@rr, @requestStatus, @requestId)

  Output(Concat('requestStatus: ', @requestStatus))
  Output(Concat('<br>requestId: ', @requestId))

  /* Looping through all found Subscribers - Ideally would be only one */
  FOR @i = 1 TO RowCount(@allSubRows) DO

    SET @allSubRow = Row(@allSubRows, @i)
    SET @subStatus = Field(@allSubRow, 'Status')

    Output(Concat('<br>subStatus: ', @subStatus))

  NEXT @i

]%%

Just remember to set beforehand the SubscriberKey in the @subscriberKey variable and it'll work just fine!

For example: SET @subscriberKey = AttributeValue('_subscriberKey')

You must log in to answer this question.

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