One-Click Unsubscribe Not WorkingOne click unsubscribeOne-click Custom UnsubscribeWhy does ExactTarget not find a subscriber in job when creating a custom unsubscribe for Salesforce integration?I can't even set variables in ExactTarget AmpScriptWithout Data Extension ? Possibilities in ExacttargetLandingpage errorcodeHow do I check if a subscriber exists in a list using ampscript on a landing page?Custom One-Click Unsubscribe not workingCalling content areas new content builderCannot submit form on custom Preference Center

Which place in our solar system is mostly fit for terraforming?

My Project Manager does not accept carry-over in Scrum, Is that normal?

How do I deal with too many NPCs in my campaign?

Is this a Sherman, and if so what model?

What is the need of methods like GET and POST in the HTTP protocol?

Late 1970's and 6502 chip facilities for operating systems

Is there a way to hide HTML source code yet keeping it effective?

How do pilots align the HUD with their eyeballs?

How can this Stack Exchange site have an animated favicon?

What benefits does the Power Word Kill spell have?

Is it possible to encode a message in such a way that can only be read by someone or something capable of seeing into the very near future?

Is there any iPhone SE out there with 3D Touch?

Why does NASA publish all the results/data it gets?

A simple game that keeps track of the number of questions asked

Is it impolite to ask for halal food when traveling to and in Thailand?

Resolving moral conflict

On the meaning of 'anyways' in "What Exactly Is a Quartz Crystal, Anyways?"

Palatino font (newpxmath) misaligns text in fraction numerators

Examples of "unsuccessful" theories with afterlives

How do you use the interjection for snorting?

How to manage expenditure when billing cycles and paycheck cycles are not aligned?

What do you do if you have developments on your paper during the long peer review process?

Piece de Resistance - Ten Quotas. Nine Passed. Your Turn

Can I take NEW (still in their boxes) PC PARTS in my checked in luggage?



One-Click Unsubscribe Not Working


One click unsubscribeOne-click Custom UnsubscribeWhy does ExactTarget not find a subscriber in job when creating a custom unsubscribe for Salesforce integration?I can't even set variables in ExactTarget AmpScriptWithout Data Extension ? Possibilities in ExacttargetLandingpage errorcodeHow do I check if a subscriber exists in a list using ampscript on a landing page?Custom One-Click Unsubscribe not workingCalling content areas new content builderCannot submit form on custom Preference Center






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I created a one-click unsubscribe. But it is not unsubscribing any user.The user is still active in all subscriber list. I've used the below code




%%[
/* declare variables */
var @sid, @jid, @listid, @batchid, @reason, @lue, @lue_prop, @lue_statusCode, @overallStatus, @requestId, @Response, @Status, @Error

/* import the personalization string values from the query string into the variables */
set @skey = AttributeValue("_subscriberkey")
set @jobid = AttributeValue("jobid")
set @listid = AttributeValue("listid")
set @batchid = AttributeValue("_JobSubscriberBatchID")

/* set the reason for the unsubscribe */
set @reason = "Custom Unsubscribe"

/* initiate the LogUnsubEvent request */
set @lue = CreateObject("ExecuteRequest")
SetObjectProperty(@lue, "Name", "LogUnsubEvent")

/* configure the properties of the API object */
set @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
SetObjectProperty(@lue_prop, "Value", @skey)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

set @lue_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "JobID")
SetObjectProperty(@lue_prop, "Value", @jobid)
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_prop = CreateObject("APIProperty")
SetObjectProperty(@lue_prop, "Name", "Reason")
SetObjectProperty(@lue_prop, "Value", @reason)
AddObjectArrayItem(@lue, "Parameters", @lue_prop)

/* you have to set the ClientID only when working with On Your Behalf accounts
var @mid, @lue_oyb
set @mid = memberid
set @lue_oyb = CreateObject('ClientID')
SetObjectProperty(@lue_oyb, 'ID', @mid)
SetObjectProperty(@lue, 'Client', @lue_oyb)
*/

/* this is where the unsubscribe is performed */
set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)
/*
set @Response = Row(@lue_statusCode, 1)
set @Status = Field(@Response, "StatusMessage")
set @Error = Field(@Response, "ErrorCode")

IF (@Error == "12012") OR (@Error == "401") OR (@Status == "Event posted") THEN
/* it worked */
ELSE
*/
/* it failed, do a normal update */
SET @sub = CreateObject("Subscriber")
SetObjectProperty(@sub, "SubscriberKey", @skey)

SET @list = CreateObject("SubscriberList")
SetObjectProperty(@list, "Status", "Unsubscribed")
SetObjectProperty(@list, "ID", @listid)
SetObjectProperty(@list, "Action", "Update")
AddObjectArrayItem(@sub, "Lists", @list)
SET @statusCode = InvokeUpdate(@sub, @statusMsg, @errorCode)
ENDIF

]%%









share|improve this question









New contributor



Ankur Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    1















    I created a one-click unsubscribe. But it is not unsubscribing any user.The user is still active in all subscriber list. I've used the below code




    %%[
    /* declare variables */
    var @sid, @jid, @listid, @batchid, @reason, @lue, @lue_prop, @lue_statusCode, @overallStatus, @requestId, @Response, @Status, @Error

    /* import the personalization string values from the query string into the variables */
    set @skey = AttributeValue("_subscriberkey")
    set @jobid = AttributeValue("jobid")
    set @listid = AttributeValue("listid")
    set @batchid = AttributeValue("_JobSubscriberBatchID")

    /* set the reason for the unsubscribe */
    set @reason = "Custom Unsubscribe"

    /* initiate the LogUnsubEvent request */
    set @lue = CreateObject("ExecuteRequest")
    SetObjectProperty(@lue, "Name", "LogUnsubEvent")

    /* configure the properties of the API object */
    set @lue_prop = CreateObject("APIProperty")
    SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
    SetObjectProperty(@lue_prop, "Value", @skey)
    AddObjectArrayItem(@lue, "Parameters", @lue_prop)

    set @lue_prop = CreateObject("APIProperty")
    SetObjectProperty(@lue_prop, "Name", "JobID")
    SetObjectProperty(@lue_prop, "Value", @jobid)
    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_prop = CreateObject("APIProperty")
    SetObjectProperty(@lue_prop, "Name", "Reason")
    SetObjectProperty(@lue_prop, "Value", @reason)
    AddObjectArrayItem(@lue, "Parameters", @lue_prop)

    /* you have to set the ClientID only when working with On Your Behalf accounts
    var @mid, @lue_oyb
    set @mid = memberid
    set @lue_oyb = CreateObject('ClientID')
    SetObjectProperty(@lue_oyb, 'ID', @mid)
    SetObjectProperty(@lue, 'Client', @lue_oyb)
    */

    /* this is where the unsubscribe is performed */
    set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)
    /*
    set @Response = Row(@lue_statusCode, 1)
    set @Status = Field(@Response, "StatusMessage")
    set @Error = Field(@Response, "ErrorCode")

    IF (@Error == "12012") OR (@Error == "401") OR (@Status == "Event posted") THEN
    /* it worked */
    ELSE
    */
    /* it failed, do a normal update */
    SET @sub = CreateObject("Subscriber")
    SetObjectProperty(@sub, "SubscriberKey", @skey)

    SET @list = CreateObject("SubscriberList")
    SetObjectProperty(@list, "Status", "Unsubscribed")
    SetObjectProperty(@list, "ID", @listid)
    SetObjectProperty(@list, "Action", "Update")
    AddObjectArrayItem(@sub, "Lists", @list)
    SET @statusCode = InvokeUpdate(@sub, @statusMsg, @errorCode)
    ENDIF

    ]%%









    share|improve this question









    New contributor



    Ankur Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      I created a one-click unsubscribe. But it is not unsubscribing any user.The user is still active in all subscriber list. I've used the below code




      %%[
      /* declare variables */
      var @sid, @jid, @listid, @batchid, @reason, @lue, @lue_prop, @lue_statusCode, @overallStatus, @requestId, @Response, @Status, @Error

      /* import the personalization string values from the query string into the variables */
      set @skey = AttributeValue("_subscriberkey")
      set @jobid = AttributeValue("jobid")
      set @listid = AttributeValue("listid")
      set @batchid = AttributeValue("_JobSubscriberBatchID")

      /* set the reason for the unsubscribe */
      set @reason = "Custom Unsubscribe"

      /* initiate the LogUnsubEvent request */
      set @lue = CreateObject("ExecuteRequest")
      SetObjectProperty(@lue, "Name", "LogUnsubEvent")

      /* configure the properties of the API object */
      set @lue_prop = CreateObject("APIProperty")
      SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
      SetObjectProperty(@lue_prop, "Value", @skey)
      AddObjectArrayItem(@lue, "Parameters", @lue_prop)

      set @lue_prop = CreateObject("APIProperty")
      SetObjectProperty(@lue_prop, "Name", "JobID")
      SetObjectProperty(@lue_prop, "Value", @jobid)
      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_prop = CreateObject("APIProperty")
      SetObjectProperty(@lue_prop, "Name", "Reason")
      SetObjectProperty(@lue_prop, "Value", @reason)
      AddObjectArrayItem(@lue, "Parameters", @lue_prop)

      /* you have to set the ClientID only when working with On Your Behalf accounts
      var @mid, @lue_oyb
      set @mid = memberid
      set @lue_oyb = CreateObject('ClientID')
      SetObjectProperty(@lue_oyb, 'ID', @mid)
      SetObjectProperty(@lue, 'Client', @lue_oyb)
      */

      /* this is where the unsubscribe is performed */
      set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)
      /*
      set @Response = Row(@lue_statusCode, 1)
      set @Status = Field(@Response, "StatusMessage")
      set @Error = Field(@Response, "ErrorCode")

      IF (@Error == "12012") OR (@Error == "401") OR (@Status == "Event posted") THEN
      /* it worked */
      ELSE
      */
      /* it failed, do a normal update */
      SET @sub = CreateObject("Subscriber")
      SetObjectProperty(@sub, "SubscriberKey", @skey)

      SET @list = CreateObject("SubscriberList")
      SetObjectProperty(@list, "Status", "Unsubscribed")
      SetObjectProperty(@list, "ID", @listid)
      SetObjectProperty(@list, "Action", "Update")
      AddObjectArrayItem(@sub, "Lists", @list)
      SET @statusCode = InvokeUpdate(@sub, @statusMsg, @errorCode)
      ENDIF

      ]%%









      share|improve this question









      New contributor



      Ankur Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I created a one-click unsubscribe. But it is not unsubscribing any user.The user is still active in all subscriber list. I've used the below code




      %%[
      /* declare variables */
      var @sid, @jid, @listid, @batchid, @reason, @lue, @lue_prop, @lue_statusCode, @overallStatus, @requestId, @Response, @Status, @Error

      /* import the personalization string values from the query string into the variables */
      set @skey = AttributeValue("_subscriberkey")
      set @jobid = AttributeValue("jobid")
      set @listid = AttributeValue("listid")
      set @batchid = AttributeValue("_JobSubscriberBatchID")

      /* set the reason for the unsubscribe */
      set @reason = "Custom Unsubscribe"

      /* initiate the LogUnsubEvent request */
      set @lue = CreateObject("ExecuteRequest")
      SetObjectProperty(@lue, "Name", "LogUnsubEvent")

      /* configure the properties of the API object */
      set @lue_prop = CreateObject("APIProperty")
      SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
      SetObjectProperty(@lue_prop, "Value", @skey)
      AddObjectArrayItem(@lue, "Parameters", @lue_prop)

      set @lue_prop = CreateObject("APIProperty")
      SetObjectProperty(@lue_prop, "Name", "JobID")
      SetObjectProperty(@lue_prop, "Value", @jobid)
      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_prop = CreateObject("APIProperty")
      SetObjectProperty(@lue_prop, "Name", "Reason")
      SetObjectProperty(@lue_prop, "Value", @reason)
      AddObjectArrayItem(@lue, "Parameters", @lue_prop)

      /* you have to set the ClientID only when working with On Your Behalf accounts
      var @mid, @lue_oyb
      set @mid = memberid
      set @lue_oyb = CreateObject('ClientID')
      SetObjectProperty(@lue_oyb, 'ID', @mid)
      SetObjectProperty(@lue, 'Client', @lue_oyb)
      */

      /* this is where the unsubscribe is performed */
      set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)
      /*
      set @Response = Row(@lue_statusCode, 1)
      set @Status = Field(@Response, "StatusMessage")
      set @Error = Field(@Response, "ErrorCode")

      IF (@Error == "12012") OR (@Error == "401") OR (@Status == "Event posted") THEN
      /* it worked */
      ELSE
      */
      /* it failed, do a normal update */
      SET @sub = CreateObject("Subscriber")
      SetObjectProperty(@sub, "SubscriberKey", @skey)

      SET @list = CreateObject("SubscriberList")
      SetObjectProperty(@list, "Status", "Unsubscribed")
      SetObjectProperty(@list, "ID", @listid)
      SetObjectProperty(@list, "Action", "Update")
      AddObjectArrayItem(@sub, "Lists", @list)
      SET @statusCode = InvokeUpdate(@sub, @statusMsg, @errorCode)
      ENDIF

      ]%%






      marketing-cloud ampscript






      share|improve this question









      New contributor



      Ankur Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question









      New contributor



      Ankur Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question








      edited 9 hours ago









      Rachid Mamai

      8551 gold badge3 silver badges12 bronze badges




      8551 gold badge3 silver badges12 bronze badges






      New contributor



      Ankur Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 9 hours ago









      Ankur NigamAnkur Nigam

      62 bronze badges




      62 bronze badges




      New contributor



      Ankur Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      Ankur Nigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























          1 Answer
          1






          active

          oldest

          votes


















          4
















          You're not checking if the variables have been populated, your code is missing if not empty rules. I suggest trying with the following script in the original version, as it was posted by Adam on his blog:



          %%[

          var @debug
          var @jid
          var @listid
          var @batchid
          var @email
          var @skey
          var @reason
          var @unsubscribeAll

          set @debug = 0
          set @jid = AttributeValue("jobid")
          set @listid = AttributeValue("listid")
          set @batchid = AttributeValue("_JobSubscriberBatchID")
          set @email = AttributeValue("emailaddr")
          set @skey = AttributeValue("_subscriberkey")
          set @reason = "One-Click Unsubscribe"
          set @unsubscribeAll = RequestParameter("ua")

          /* if we know the subscriber */
          if not empty(@skey) then

          var @lue
          var @lue_prop
          var @lue_statusCode
          var @overallStatus
          var @requestId
          var @Response
          var @Status
          var @Error

          /* if unsubscribing from all, then set the job, batch and listids to blank, effectively doing a global unsub */
          if @unsubscribeAll == "1" then
          set @jid = ""
          set @listid = ""
          set @batchid = ""
          endif

          /* create a request to inject an unsub event into the LogUnsubEvent platform table */
          set @lue = CreateObject("ExecuteRequest")
          SetObjectProperty(@lue,"Name","LogUnsubEvent")

          /*
          In order to invoke the request, we need to associate the following information with it to define the subscriber context and the job context:

          1. Subscriber Key
          2. JobId associated with the email send
          3. ListID the email was sent to
          4. BatchID the email was sent to
          5. Reason for the unsub
          */

          /* 1. define and associate Subscriber Key to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
          SetObjectProperty(@lue_prop, "Value", @skey)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* 2. define and associate JobID to the request */
          if not empty(@jid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "JobID")
          SetObjectProperty(@lue_prop, "Value", @jid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 3. define and associate ListID to the request */
          if not empty(@listid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "ListID")
          SetObjectProperty(@lue_prop, "Value", @listid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 4. define and associate BatchID to the request */
          if not empty(@batchid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "BatchID")
          SetObjectProperty(@lue_prop, "Value", @batchid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 5. define and associate unsub reason to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "Reason")
          SetObjectProperty(@lue_prop, "Value", @reason)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* finally, you invoke the request */
          set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

          /* extract messages from the response */
          set @Response = Row(@lue_statusCode, 1)
          set @Status = Field(@Response,"StatusMessage")
          set @Error = Field(@Response,"ErrorCode")

          endif

          if @debug == 1 then
          output(concat("<br>jid: ", @jid))
          output(concat("<br>listid: ", @listid))
          output(concat("<br>batchid: ", @batchid))
          output(concat("<br>email: ", @email))
          output(concat("<br>skey: ", @skey))
          output(concat("<br>reason: ", @reason))
          output(concat("<br>unsubscribeAll: ", @unsubscribeAll))
          output(concat("<br>overallStatus: ", @overallStatus))
          output(concat("<br>requestId: ", @requestId))
          output(concat("<br>Response: ", @Response))
          output(concat("<br>Status: ", @Status))
          output(concat("<br>Error: ", @Error))
          endif

          ]%%





          share|improve this answer




















          • 1





            Also, unsub events are not always immediate. I've gotten tripped up by that in testing. Debugging output helps in testing, also.

            – Adam Spriggs
            7 hours ago













          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "459"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );







          Ankur Nigam is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f278867%2fone-click-unsubscribe-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4
















          You're not checking if the variables have been populated, your code is missing if not empty rules. I suggest trying with the following script in the original version, as it was posted by Adam on his blog:



          %%[

          var @debug
          var @jid
          var @listid
          var @batchid
          var @email
          var @skey
          var @reason
          var @unsubscribeAll

          set @debug = 0
          set @jid = AttributeValue("jobid")
          set @listid = AttributeValue("listid")
          set @batchid = AttributeValue("_JobSubscriberBatchID")
          set @email = AttributeValue("emailaddr")
          set @skey = AttributeValue("_subscriberkey")
          set @reason = "One-Click Unsubscribe"
          set @unsubscribeAll = RequestParameter("ua")

          /* if we know the subscriber */
          if not empty(@skey) then

          var @lue
          var @lue_prop
          var @lue_statusCode
          var @overallStatus
          var @requestId
          var @Response
          var @Status
          var @Error

          /* if unsubscribing from all, then set the job, batch and listids to blank, effectively doing a global unsub */
          if @unsubscribeAll == "1" then
          set @jid = ""
          set @listid = ""
          set @batchid = ""
          endif

          /* create a request to inject an unsub event into the LogUnsubEvent platform table */
          set @lue = CreateObject("ExecuteRequest")
          SetObjectProperty(@lue,"Name","LogUnsubEvent")

          /*
          In order to invoke the request, we need to associate the following information with it to define the subscriber context and the job context:

          1. Subscriber Key
          2. JobId associated with the email send
          3. ListID the email was sent to
          4. BatchID the email was sent to
          5. Reason for the unsub
          */

          /* 1. define and associate Subscriber Key to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
          SetObjectProperty(@lue_prop, "Value", @skey)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* 2. define and associate JobID to the request */
          if not empty(@jid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "JobID")
          SetObjectProperty(@lue_prop, "Value", @jid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 3. define and associate ListID to the request */
          if not empty(@listid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "ListID")
          SetObjectProperty(@lue_prop, "Value", @listid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 4. define and associate BatchID to the request */
          if not empty(@batchid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "BatchID")
          SetObjectProperty(@lue_prop, "Value", @batchid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 5. define and associate unsub reason to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "Reason")
          SetObjectProperty(@lue_prop, "Value", @reason)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* finally, you invoke the request */
          set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

          /* extract messages from the response */
          set @Response = Row(@lue_statusCode, 1)
          set @Status = Field(@Response,"StatusMessage")
          set @Error = Field(@Response,"ErrorCode")

          endif

          if @debug == 1 then
          output(concat("<br>jid: ", @jid))
          output(concat("<br>listid: ", @listid))
          output(concat("<br>batchid: ", @batchid))
          output(concat("<br>email: ", @email))
          output(concat("<br>skey: ", @skey))
          output(concat("<br>reason: ", @reason))
          output(concat("<br>unsubscribeAll: ", @unsubscribeAll))
          output(concat("<br>overallStatus: ", @overallStatus))
          output(concat("<br>requestId: ", @requestId))
          output(concat("<br>Response: ", @Response))
          output(concat("<br>Status: ", @Status))
          output(concat("<br>Error: ", @Error))
          endif

          ]%%





          share|improve this answer




















          • 1





            Also, unsub events are not always immediate. I've gotten tripped up by that in testing. Debugging output helps in testing, also.

            – Adam Spriggs
            7 hours ago















          4
















          You're not checking if the variables have been populated, your code is missing if not empty rules. I suggest trying with the following script in the original version, as it was posted by Adam on his blog:



          %%[

          var @debug
          var @jid
          var @listid
          var @batchid
          var @email
          var @skey
          var @reason
          var @unsubscribeAll

          set @debug = 0
          set @jid = AttributeValue("jobid")
          set @listid = AttributeValue("listid")
          set @batchid = AttributeValue("_JobSubscriberBatchID")
          set @email = AttributeValue("emailaddr")
          set @skey = AttributeValue("_subscriberkey")
          set @reason = "One-Click Unsubscribe"
          set @unsubscribeAll = RequestParameter("ua")

          /* if we know the subscriber */
          if not empty(@skey) then

          var @lue
          var @lue_prop
          var @lue_statusCode
          var @overallStatus
          var @requestId
          var @Response
          var @Status
          var @Error

          /* if unsubscribing from all, then set the job, batch and listids to blank, effectively doing a global unsub */
          if @unsubscribeAll == "1" then
          set @jid = ""
          set @listid = ""
          set @batchid = ""
          endif

          /* create a request to inject an unsub event into the LogUnsubEvent platform table */
          set @lue = CreateObject("ExecuteRequest")
          SetObjectProperty(@lue,"Name","LogUnsubEvent")

          /*
          In order to invoke the request, we need to associate the following information with it to define the subscriber context and the job context:

          1. Subscriber Key
          2. JobId associated with the email send
          3. ListID the email was sent to
          4. BatchID the email was sent to
          5. Reason for the unsub
          */

          /* 1. define and associate Subscriber Key to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
          SetObjectProperty(@lue_prop, "Value", @skey)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* 2. define and associate JobID to the request */
          if not empty(@jid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "JobID")
          SetObjectProperty(@lue_prop, "Value", @jid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 3. define and associate ListID to the request */
          if not empty(@listid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "ListID")
          SetObjectProperty(@lue_prop, "Value", @listid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 4. define and associate BatchID to the request */
          if not empty(@batchid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "BatchID")
          SetObjectProperty(@lue_prop, "Value", @batchid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 5. define and associate unsub reason to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "Reason")
          SetObjectProperty(@lue_prop, "Value", @reason)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* finally, you invoke the request */
          set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

          /* extract messages from the response */
          set @Response = Row(@lue_statusCode, 1)
          set @Status = Field(@Response,"StatusMessage")
          set @Error = Field(@Response,"ErrorCode")

          endif

          if @debug == 1 then
          output(concat("<br>jid: ", @jid))
          output(concat("<br>listid: ", @listid))
          output(concat("<br>batchid: ", @batchid))
          output(concat("<br>email: ", @email))
          output(concat("<br>skey: ", @skey))
          output(concat("<br>reason: ", @reason))
          output(concat("<br>unsubscribeAll: ", @unsubscribeAll))
          output(concat("<br>overallStatus: ", @overallStatus))
          output(concat("<br>requestId: ", @requestId))
          output(concat("<br>Response: ", @Response))
          output(concat("<br>Status: ", @Status))
          output(concat("<br>Error: ", @Error))
          endif

          ]%%





          share|improve this answer




















          • 1





            Also, unsub events are not always immediate. I've gotten tripped up by that in testing. Debugging output helps in testing, also.

            – Adam Spriggs
            7 hours ago













          4














          4










          4









          You're not checking if the variables have been populated, your code is missing if not empty rules. I suggest trying with the following script in the original version, as it was posted by Adam on his blog:



          %%[

          var @debug
          var @jid
          var @listid
          var @batchid
          var @email
          var @skey
          var @reason
          var @unsubscribeAll

          set @debug = 0
          set @jid = AttributeValue("jobid")
          set @listid = AttributeValue("listid")
          set @batchid = AttributeValue("_JobSubscriberBatchID")
          set @email = AttributeValue("emailaddr")
          set @skey = AttributeValue("_subscriberkey")
          set @reason = "One-Click Unsubscribe"
          set @unsubscribeAll = RequestParameter("ua")

          /* if we know the subscriber */
          if not empty(@skey) then

          var @lue
          var @lue_prop
          var @lue_statusCode
          var @overallStatus
          var @requestId
          var @Response
          var @Status
          var @Error

          /* if unsubscribing from all, then set the job, batch and listids to blank, effectively doing a global unsub */
          if @unsubscribeAll == "1" then
          set @jid = ""
          set @listid = ""
          set @batchid = ""
          endif

          /* create a request to inject an unsub event into the LogUnsubEvent platform table */
          set @lue = CreateObject("ExecuteRequest")
          SetObjectProperty(@lue,"Name","LogUnsubEvent")

          /*
          In order to invoke the request, we need to associate the following information with it to define the subscriber context and the job context:

          1. Subscriber Key
          2. JobId associated with the email send
          3. ListID the email was sent to
          4. BatchID the email was sent to
          5. Reason for the unsub
          */

          /* 1. define and associate Subscriber Key to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
          SetObjectProperty(@lue_prop, "Value", @skey)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* 2. define and associate JobID to the request */
          if not empty(@jid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "JobID")
          SetObjectProperty(@lue_prop, "Value", @jid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 3. define and associate ListID to the request */
          if not empty(@listid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "ListID")
          SetObjectProperty(@lue_prop, "Value", @listid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 4. define and associate BatchID to the request */
          if not empty(@batchid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "BatchID")
          SetObjectProperty(@lue_prop, "Value", @batchid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 5. define and associate unsub reason to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "Reason")
          SetObjectProperty(@lue_prop, "Value", @reason)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* finally, you invoke the request */
          set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

          /* extract messages from the response */
          set @Response = Row(@lue_statusCode, 1)
          set @Status = Field(@Response,"StatusMessage")
          set @Error = Field(@Response,"ErrorCode")

          endif

          if @debug == 1 then
          output(concat("<br>jid: ", @jid))
          output(concat("<br>listid: ", @listid))
          output(concat("<br>batchid: ", @batchid))
          output(concat("<br>email: ", @email))
          output(concat("<br>skey: ", @skey))
          output(concat("<br>reason: ", @reason))
          output(concat("<br>unsubscribeAll: ", @unsubscribeAll))
          output(concat("<br>overallStatus: ", @overallStatus))
          output(concat("<br>requestId: ", @requestId))
          output(concat("<br>Response: ", @Response))
          output(concat("<br>Status: ", @Status))
          output(concat("<br>Error: ", @Error))
          endif

          ]%%





          share|improve this answer













          You're not checking if the variables have been populated, your code is missing if not empty rules. I suggest trying with the following script in the original version, as it was posted by Adam on his blog:



          %%[

          var @debug
          var @jid
          var @listid
          var @batchid
          var @email
          var @skey
          var @reason
          var @unsubscribeAll

          set @debug = 0
          set @jid = AttributeValue("jobid")
          set @listid = AttributeValue("listid")
          set @batchid = AttributeValue("_JobSubscriberBatchID")
          set @email = AttributeValue("emailaddr")
          set @skey = AttributeValue("_subscriberkey")
          set @reason = "One-Click Unsubscribe"
          set @unsubscribeAll = RequestParameter("ua")

          /* if we know the subscriber */
          if not empty(@skey) then

          var @lue
          var @lue_prop
          var @lue_statusCode
          var @overallStatus
          var @requestId
          var @Response
          var @Status
          var @Error

          /* if unsubscribing from all, then set the job, batch and listids to blank, effectively doing a global unsub */
          if @unsubscribeAll == "1" then
          set @jid = ""
          set @listid = ""
          set @batchid = ""
          endif

          /* create a request to inject an unsub event into the LogUnsubEvent platform table */
          set @lue = CreateObject("ExecuteRequest")
          SetObjectProperty(@lue,"Name","LogUnsubEvent")

          /*
          In order to invoke the request, we need to associate the following information with it to define the subscriber context and the job context:

          1. Subscriber Key
          2. JobId associated with the email send
          3. ListID the email was sent to
          4. BatchID the email was sent to
          5. Reason for the unsub
          */

          /* 1. define and associate Subscriber Key to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
          SetObjectProperty(@lue_prop, "Value", @skey)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* 2. define and associate JobID to the request */
          if not empty(@jid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "JobID")
          SetObjectProperty(@lue_prop, "Value", @jid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 3. define and associate ListID to the request */
          if not empty(@listid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "ListID")
          SetObjectProperty(@lue_prop, "Value", @listid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 4. define and associate BatchID to the request */
          if not empty(@batchid) then
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "BatchID")
          SetObjectProperty(@lue_prop, "Value", @batchid)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)
          endif

          /* 5. define and associate unsub reason to the request */
          set @lue_prop = CreateObject("APIProperty")
          SetObjectProperty(@lue_prop, "Name", "Reason")
          SetObjectProperty(@lue_prop, "Value", @reason)
          AddObjectArrayItem(@lue, "Parameters", @lue_prop)

          /* finally, you invoke the request */
          set @lue_statusCode = InvokeExecute(@lue, @overallStatus, @requestId)

          /* extract messages from the response */
          set @Response = Row(@lue_statusCode, 1)
          set @Status = Field(@Response,"StatusMessage")
          set @Error = Field(@Response,"ErrorCode")

          endif

          if @debug == 1 then
          output(concat("<br>jid: ", @jid))
          output(concat("<br>listid: ", @listid))
          output(concat("<br>batchid: ", @batchid))
          output(concat("<br>email: ", @email))
          output(concat("<br>skey: ", @skey))
          output(concat("<br>reason: ", @reason))
          output(concat("<br>unsubscribeAll: ", @unsubscribeAll))
          output(concat("<br>overallStatus: ", @overallStatus))
          output(concat("<br>requestId: ", @requestId))
          output(concat("<br>Response: ", @Response))
          output(concat("<br>Status: ", @Status))
          output(concat("<br>Error: ", @Error))
          endif

          ]%%






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 8 hours ago









          CodeRageCodeRage

          1,8101 gold badge3 silver badges19 bronze badges




          1,8101 gold badge3 silver badges19 bronze badges










          • 1





            Also, unsub events are not always immediate. I've gotten tripped up by that in testing. Debugging output helps in testing, also.

            – Adam Spriggs
            7 hours ago












          • 1





            Also, unsub events are not always immediate. I've gotten tripped up by that in testing. Debugging output helps in testing, also.

            – Adam Spriggs
            7 hours ago







          1




          1





          Also, unsub events are not always immediate. I've gotten tripped up by that in testing. Debugging output helps in testing, also.

          – Adam Spriggs
          7 hours ago





          Also, unsub events are not always immediate. I've gotten tripped up by that in testing. Debugging output helps in testing, also.

          – Adam Spriggs
          7 hours ago











          Ankur Nigam is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded

















          Ankur Nigam is a new contributor. Be nice, and check out our Code of Conduct.












          Ankur Nigam is a new contributor. Be nice, and check out our Code of Conduct.











          Ankur Nigam is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f278867%2fone-click-unsubscribe-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

          Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

          François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480