Skip to main content
added 2 characters in body
Source Link
D4MG
  • 36
  • 4

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'_subscriberKey')

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)

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')

Source Link
D4MG
  • 36
  • 4

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)