1

Hi I have a custom unsubscribe page on which i have a checkbox with submit button.

By using these i want to unsubscribe the subscriber from All subscribers. I am using the below code code and getting 500 internal server error.

    %%[
        IF not empty(requestParameter("submit")) THEN
    
    //SET @subkey = RequestParameter("Subscriberkey")
       // SET @email = RequestParameter("EmailAddress")
    
         SET @subkey = "hardcoded for testing"
        SET @email = "hardcoded for testing"
        
       /* Unsubscribe Subscriber in ET All Subscribers */
    SET @sub = CreateObject("Subscriber")
    SetObjectProperty(@sub,"SubscriberKey", @subkey)
    SetObjectProperty(@sub,"Status", "Unsubscribed")
    
    Set @options = CreateObject("UpdateOptions")
    Set @save = CreateObject("SaveOption")
    SetObjectProperty(@save,"SaveAction","UpdateAdd")
    SetObjectProperty(@save,"PropertyName","*")
    AddObjectArrayItem(@options,"SaveOptions", @save)
    
    /* Here is where we actually update the Subscriber object */
    Set @ll_statusCode = InvokeUpdate(@sub, @ll_statusMsg, @update_sub_errorcode, @options)
    
        IF @ll_statusCode == "OK" THEN
            Redirect("https://pub.s4.exacttarget.com/ts2vjt4qghl")
        ELSE
            RaiseError(@ll_statusMsg, 0, @ll_statusCode, @errorCode)
        ENDIF
        
    ENDIF
    ]%%

2 Answers 2

2

I got this solution to work. I was using same submit button name with in the page it's throwing error . I changed the submit button name.

    <!--%%[
    var @subkey
    var @email
    IF not empty(requestParameter("Update")) THEN
    
    SET @subkey = RequestParameter("Subscriberkey")
    SET @email = RequestParameter("EmailAddress")    
        
    /* Unsubscribe Subscriber in ET All Subscribers */
    SET @sub = CreateObject("Subscriber")
    SetObjectProperty(@sub,"SubscriberKey", @subkey)
    SetObjectProperty(@sub,"Status", "Unsubscribed")
    
    Set @options = CreateObject("UpdateOptions")
    Set @save = CreateObject("SaveOption")
    SetObjectProperty(@save,"SaveAction","UpdateAdd")
    SetObjectProperty(@save,"PropertyName","*")
    AddObjectArrayItem(@options,"SaveOptions", @save)
    
    /* Here is where we actually update the Subscriber object */
    Set @ll_statusCode = InvokeUpdate(@sub, @ll_statusMsg, @update_sub_errorcode, @options)
    
        IF @ll_statusCode == "OK" THEN
            Redirect("https://pub.s4.exacttarget.com/ts2vjt4qghl")
        ELSE
            RaiseError(@ll_statusMsg, 0, @ll_statusCode, @errorCode)
        ENDIF
        
    ENDIF
    ]%%

-->
<br>
<br>
Unsubscribe From All
<br>
<br>

<label>
Text goes here
 </label>
<br>
<br>
 <input id="UnsubscribeAll" type="checkbox" name="UnsubscribeAll" value="AllSubscribers">
  <label>I no longer wish to receive any future publications.
  </label>
<br>
<br>
<input type="submit" name="Update" value="Update">
1

I believe you will want to use LogUnsubEvent instead of Subscriber Object.

Why Use the LogUnsubEvent?
Execute Call Use this call when you create your own landing page or profile center functionality. Previously, you could unsubscribe a subscriber, but you could not create and log the UnsubEvent.

Sample SOAP

<soap-ENV:Body>
    <ExecuteRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Requests>
            <Name>LogUnsubEvent</Name>
            <Parameters>
                <Name>SubscriberID</Name>
                <Value>123456</Value>
            </Parameters>
            <Parameters>
                <Name>SubscriberKey</Name>
                <Value>Key for [email protected]</Value>
            </Parameters>
            <Parameters>
                <Name>EmailAddress</Name>
                <Value>[email protected]</Value>
            </Parameters>
            <Parameters>
                <Name>JobID</Name>
                <Value>18099</Value>
            </Parameters>
            <Parameters>
                <Name>ListID</Name>
                <Value>17914</Value>
            </Parameters>
            <Parameters>
                <Name>BatchID</Name>
                <Value>0</Value>
            </Parameters>
        </Requests>
    </ExecuteRequestMsg>
</SOAP-ENV:Body>
2
  • Hi Gortonington thanks for the response. I got the subscriber object code to work it was the requestParameter submit. With in the same page there was another button with the same name that's the root cause for the issue i have. Aug 31, 2017 at 15:38
  • 1
    Glad you were able to find the solution. Perhaps to help others that have a similar issue, if you could post an answer with your solution and then later accept as the correct answer so that others can reference it. Aug 31, 2017 at 18:32

You must log in to answer this question.

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