4

I am trying to build a custom subscription center that will add or delete a subscriber from a suppression list. I have been successful when adding subscribers to a data extension and was hoping I can follow a similar structure. The code below doesn't give me an exception but it doesn't add the subscriber either.

I would greatly appreciate any help to get me on the right track.

Thanks in advance!

/* ADDING A SUBSCRIBER TO A SUPPRESSION LIST */

VAR @sup_list, @sup_list_col, @sup_list_statusCode, @sup_list_statusMsg, @sup_list_list, @sup_list_subkey, @sup_list_errorCode


SET @sup_list = CreateObject("SuppressionListData")
SetObjectProperty(@sup_list, "PartnerKey", "[Name of suppression list]")


SET @sup_list_col = CreateObject("APIProperty")
SetObjectProperty(@sup_list_col, "Name", "Email Address")
SetObjectProperty(@sup_list_col, "Value",@EmailAddress)
AddObjectArrayItem(@sup_list, "PartnerProperties", @sup_list_col)


SET @sup_list_col = CreateObject("APIProperty")
SetObjectProperty(@sup_list_col, "Name", "Subscriber Key")
SetObjectProperty(@sup_list_col, "Value",@subkey)
AddObjectArrayItem(@sup_list, "Properties", @sup_list_col)

SET @sup_list_statusCode = InvokeCreate(@sup_list, @sup_list_statusMsg, @sup_list_errorCode)

IF @sup_list_statusCode != "OK" THEN
    RaiseError(@sup_list_statusMsg, 0, @sup_list_statusCode, @sup_list_errorCode)
ENDIF

1 Answer 1

5

It seems like using publication lists is better for this purpose. I used the following code to achieve my goal:

SET @rr = CreateObject("RetrieveRequest") 

SetObjectProperty(@rr, "ObjectType", "List")
 AddObjectArrayItem(@rr,"Properties","ListName") 
 AddObjectArrayItem(@rr,"Properties","ID")

SET @sfp = CreateObject("SimpleFilterPart")
 SetObjectProperty(@sfp, "Property", "ListName")
 SetObjectProperty(@sfp, "SimpleOperator", "equals")
 AddObjectArrayItem(@sfp, "Value",@PublicationType)
 SetObjectProperty(@rr, "Filter", @sfp) 

SET @Sub = InvokeRetrieve(@rr) 

Set @ListID = Field(Row(@Sub,1),"ID")

SET @ll_sub = CreateObject("Subscriber")
SetObjectProperty(@ll_sub, "EmailAddress", @EmailAddress)
SetObjectProperty(@ll_sub, "SubscriberKey", @subKey)


set @subscription = CreateObject("SubscriberList")
SetObjectProperty( @subscription, "ID",@ListID)
SetObjectProperty( @subscription, "IDSpecified", "true" )
SetObjectProperty( @subscription, "Status", "Unsubscribed" )
SetObjectProperty( @subscription, "StatusSpecified", "true" )
AddObjectArrayItem( @ll_sub, "Lists", @subscription )

SET @ll_statusCode = InvokeUpdate(@ll_sub, @ll_statusMsg, @errorCode)

IF @ll_statusCode != "OK" THEN
    RaiseError(@ll_statusMsg, 0, @ll_statusCode, @errorCode)
ENDIF

You must log in to answer this question.

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