1

So my unsub page is located at the parent BU and we unsubscribe based on child BU's. We have a specific child BU that will be implementing publication lists so im trying to unsubscribe from the child's indivdual publication lists. So a user could be on 2 lists but be unsubbed from one and still be on the other

I have the following code which currently works correctly by unsubscribing from the publication list but also unsubscribes from all subscribers so then they cant receive emails if they are on a different publication list. How do i keep the unsubscribe at the publication list level?

EDIT: code has been updated to pull in listID and JobID and no longer loop

%%[
SET @jid = RequestParameter("jobid")
SET @listid = RequestParameter("listid")
SET @batchid = RequestParameter("batchid")
SET @SubscriberKey = RequestParameter("SubscriberKey")
SET @EmailAddress = RequestParameter("email_address")
SET @reason = "Unsub-Custom Landing Page"
SET @ClientID = "7326442"

/* create unsub event for unsub 

SET @subkey4unsub_event = @SubscriberKey

IF NOT EMPTY(@jid) THEN

set @lue = CreateObject("ExecuteRequest")
SetObjectProperty(@lue,"Name","LogUnsubEvent")
set @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
SetObjectProperty(@lue_prop, "Value", @subkey4unsub_event)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

set @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "Reason")
SetObjectProperty(@lue_prop, "Value", @reason)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

set @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "JobID")
SetObjectProperty(@lue_prop, "Value", @jid)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

set @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "ListID")
SetObjectProperty(@lue_prop, "Value", @listid)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

set @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "BatchID")
SetObjectProperty(@lue_prop, "Value", @batchid)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

set @Response = Row(@lue_statusCode, 1)
set @Status= Field(@Response,"StatusMessage")
set @update_sub_errorcode = Field(@Response,"ErrorCode")

ENDIF
 */


/* Change subscriber status to unsub 


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)
 */
]%%
4

The code above doesn't specify a publication list at all, so it is unsubbing at the child BU level and flowing down to the publist automatically.

This example will work (but will not log an unsub event).

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", "YourPubListIDHere")
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)

If you are wanting to use LogUnsubEvent then you may wish to reevaluate your approach with looping through subscriber records. You are searching for a Sent event in order to get the jobID etc but if for whatever reason it cannot find one then they will be Master Unsubscribed. See documentation specifically the Job Context section.

If the job context cannot be established because you did not supply any of these parameters or only supplied the BatchID, the UnsubEvent is not created. The subscriber is also Master Unsubscribed from the system instead of being unsubscribed from a particular list

You will also want to include the ClientID.

If you make this call from the parent unit of an Enterprise 2.0 account, ensure that you include the ClientID of the child business account to return information specific to that business unit.

  • When inserting that code directly to replace my other code posted above, I am no longer able to return my jobID, listID or batchID. I am not touching anything else so i cant figure out what is breaking when i insert your snippet in place of mine. I edited my initial question with the majority of my code – LD Jewell Dec 3 '19 at 17:34
  • @LDJewell I've updated my answer. – Josh de Blank Dec 3 '19 at 22:59
  • I have updated code to no longer loop in order to get JobID and ListID and rather passing them through parameters. I am successfully getting them on my confirmation page but now when i go to publish, it wont. Commenting out the unsub piece allows it to publish which makes me believe it is something in that unsub code part. I have checked all variables being used and they are being set and populated correctly. Any other ideas? Thank you for the help – LD Jewell Dec 4 '19 at 22:47

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.