I'm having problems on an unsubscribe page when i add an insertDATA function. The page is working well without this function.
SO i try to insert "SubscriberID" (Data type is texte 50 length, and it's the Primary key) and "rm_optin_c" = false (data type is Boolean, nullable is true and default value is "false") into the DE "DE_TAMPON_Unsub_Pref_Page".
The code that makes the Cloudpage error is this one :
Set @optintampon = 'false'
set @insertoptin = insertData("DE_TAMPON_Unsub_Pref_Page", "rm_optin_c", @optintampon, "SubscriberID", @subkey)
The AMP for the entire Cloudpage is
set @subkey = _subscriberKey
set @email = AttributeValue("emailaddr")
set @brandnlspecialoccasion = IIF(RequestParameter("brandnlspecialoccasion")=='on','true','false')
set @cocktailinspiration = IIF(RequestParameter("cocktailinspiration")=='on','true','false')
set @distillerynews = IIF(RequestParameter("distillerynews")=='on','true','false')
IF (@brandnlspecialoccasion == 'false' AND @cocktailinspiration == 'false' and @distillerynews == 'false') then
set @version = 'A'
set @updateRecord = UpdateSingleSalesforceObject(
"Contact", @subkey,
"Newsletter_subscription_Brand_News_Sp__c", @brandnlspecialoccasion,
"NewsletterSubscriptionCocktailInspirat__c", @cocktailinspiration,
"Newsletter_subscription_Dystillerie__c", @distillerynews,
"rm_OptIn__c","false"
);
Set @optintampon = 'false'
set @insertoptin = insertData("DE_TAMPON_Unsub_Pref_Page", "rm_optin_c", @optintampon, "SubscriberID", @subkey)
else
set @version = 'B'
set @updateRecord = UpdateSingleSalesforceObject(
"Contact", @subkey,
"Newsletter_subscription_Brand_News_Sp__c", @brandnlspecialoccasion,
"NewsletterSubscriptionCocktailInspirat__c", @cocktailinspiration,
"Newsletter_subscription_Dystillerie__c", @distillerynews
);
ENDIF
IF RequestParameter("submitted") == true THEN
set @optinglobal = IIF(RequestParameter("Email_Opt_in")=='on','true','false')
IF @optinglobal == 'true' THEN
set @updateRecord2 = UpdateSingleSalesforceObject(
"Contact", @subkey,
"rm_OptIn__c","true"
);
ENDIF
ENDIF
]%%
Does anyone know why adding the insertData line makes the whole Page an error 500 ?
try... catch
statement? That could potentially return the error. Other than that, does a record for this particular SubscriberID already exist in the DE? You could potentially try changing the function fromInsertData
toUpsertData
to avoid a primary key violation error.rm_optin_c
is of the Boolean data type in the data extension? Currently you set the value as'false'
which is a string, maybe try one of these:Set @optintampon = false
orSet @optintampon = 0
rm_optin_
is Boolean data type in the DE. i tryed to set@optintampon
tofalse or 0
but it still tells me that i cannot publish the cloud page_subscriberkey
.