0

I am trying to create custom unsubscribe for publication lists. I want to dynamically pull in the list id which is being passed through parameters. I know the id is being stored because it's showing when I output it. when I use @listid vs the actual id like 1234 my cloud page won't publish. Can I not use a variable for the id? would I just have to make an if-else block?

It seems to be able to use a variable when creating the client object and I use @ClientID.

I am pretty sure it is something in the block where I am creating the SubscriberList object because removing it all together allows the page to publish as well.

SET @jid = RequestParameter("jobid")
SET @listid = RequestParameter("listid")
SET @SubscriberKey = RequestParameter("SubscriberKey")
SET @EmailAddress = RequestParameter("email_address")
SET @ClientID = "7326442"


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

SET @client = CreateObject("ClientID")
SetObjectProperty(@client, "ID", @ClientID)
SetObjectProperty(@client, "IDSpecified", "true")
SetObjectProperty(@ll_sub, "Client", @client)

SET @List = CreateObject("SubscriberList")
SetObjectProperty(@List, "ID", @listid)
SetObjectProperty(@List, "Status", "Unsubscribed")
AddObjectArrayItem(@ll_sub, "Lists", @List)

Set @options = CreateObject("UpdateOptions")
Set @save = CreateObject("SaveOption")
SetObjectProperty(@save,"SaveAction","UpdateAdd")
SetObjectProperty(@save,"PropertyName","Status")
AddObjectArrayItem(@options,"SaveOptions", @save) 
Set @update_sub = InvokeUpdate(@ll_sub,@update_sub_status,@update_sub_errorcode, @options)
  • So i changed 'ID' to 'objectID' and it now accepts my variable ID and unsubs from the correct list. Will this method give me any problems that im not seeing currently? SetObjectProperty(@List, "ID", @listid) SetObjectProperty(@List, "ObjectID", @listid) – LD Jewell Dec 6 '19 at 18:49
0

I believe you have to include the specified properties -- IDSpecified and StatusSpecified:

SET @List = CreateObject("SubscriberList")
SetObjectProperty(@List, "ID", @listid)
SetObjectProperty(@List, "IDSpecified", "true" )
SetObjectProperty(@List, "Status", "Unsubscribed")
SetObjectProperty(@List, "StatusSpecified", "true" )
AddObjectArrayItem(@ll_sub, "Lists", @List)

Reference: Add Subscribers to a List

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.