0

I have developed a custom ampscript in a cloud page for unsubscribing the subscriber from the Business unit only and the BU settings in the admin are also made it to unsubscribe from the BU specific only. But in the below-mentioned script written for the leads(00Q), it unsubscribes from the Parent BU and for PersonAccount it works well(003). What could be the reason behind it and how to resolve:-

%%[

set @SubKey= "00Qdddeergghekkk"
set @jid= requestparameter("jobid")
set @listid= requestparameter("listid")

 SET @lue = CreateObject("ExecuteRequest")
 SetObjectProperty(@lue,"Name","LogUnsubEvent")

 SET @lue_prop = CreateObject("APIProperty")                 
 SetObjectProperty(@lue_prop, "Name", "SubscriberKey")
 SetObjectProperty(@lue_prop, "Value", @SubKey)
 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)


var @lue_oyb 
set @lue_oyb = CreateObject('ClientID') 
SetObjectProperty(@lue_oyb, 'ID','450667863')
SetObjectProperty(@lue, 'Client', @lue_oyb)


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

 SET @Response = Row(@lue_statusCode, 1)
 SET @Status = Field(@Response,"StatusMessage")
 SET @Error = Field(@Response,"ErrorCode")
     
  SET @initialValue = Substring(@SubKey,1,3)
  SET @DEName = AttributeValue("_DataSourceName")
     
    SET @PersonContactID = ""
    SET @updateRecord =0

    IF @initialValue == "003" THEN
      set @AID = LookupRows("Accounts","PersonContactID",@SubKey)
      set @row = row(@AID, 1) 
      set @PersonContactID = field(@row,"Id")
      
    ENDIF
    
   IF @initialValue == "003" THEN
   SET @updateRecord = UpdateSingleSalesforceObject("Account",@PersonContactID,"MTI_Email_Opt_Out__c",1)
  
  ELSEIF @initialValue == "00Q" THEN
    SET @updateRecord = UpdateSingleSalesforceObject("Lead",@SubKey,"MTI_Email_Opt_Out__c",1)
    ENDIF
    
    
    
]%%
<!doctype html>
<html>
<head>

<meta charset="UTF-8">
<title>Processing Page</title>
<link rel="stylesheet" href="https://pub.s6.exacttarget.com/pijsfgl2arw" type="text/css">
<style>
body {
    background: #1F222E;
}

</style>
</head>

<body>
<div>
<h1>unsubscribed 123s456a. //%%=v(@SubKey)=%%// //%%=v(@updateRecord)=%%////%%=v(@lue_statusCode)=%%// //%%=v(@Response)=%%////%%=v(@Status)=%%// //%%=v(@Error)=%%//</h1>
<div>
</body>
</html>

Your Answer

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

Browse other questions tagged or ask your own question.