0

I've tweaked our custom user preference center in Marketing Cloud, that was originally setup by our implementation team, to add another checkbox for sub/unsubs. However when I add the new field I'm getting a 500 server error.

I'm sure it's something related to what I've added but for the life of me I can't figure it out. The new field is being synced on both contacts and leads just like the other fields but something in this JSON is causing problems.

Here's the code that I've added (new line bolded):

SET @Student_Communications__c = RequestParameter("Student_Communications__c")
**SET @Emeritus_Communication__c = RequestParmaeter("Emeritus_Communication__c")**
SET @Student_Newsletter__c = RequestParameter("Student_Newsletter__c")
SET @Community_Marketing_Communications__c = RequestParameter("Community_Marketing_Communications__c")
SET @Workforce_Advancement_Marketing_Comm__c = RequestParameter("Workforce_Advancement_Marketing_Comm__c")

And I added Emeritus_Communication__c in the sections below.

 If (Substring(@SubscriberKey,1,3) == "00Q") Then
          set @result = UpdateSingleSalesforceObject('Lead',@SubscriberKey,"Student_Communications__c", @Student_Communications__c, "Emeritus_Communication__c", @Emeritus_Communication__c, "Student_Newsletter__c", @Student_Newsletter__c, "Community_Marketing_Communications__c", @Community_Marketing_Communications__c, "Workforce_Advancement_Marketing_Comm__c", @Workforce_Advancement_Marketing_Comm__c)
       EndIf

       If (Substring(@SubscriberKey,1,3) == "003") Then
          set @result = UpdateSingleSalesforceObject('Contact',@SubscriberKey,"Student_Communications__c", @Student_Communications__c, "Emeritus_Communication__c", @Emeritus_Communication__c, "Student_Newsletter__c", @Student_Newsletter__c, "Community_Marketing_Communications__c", @Community_Marketing_Communications__c, "Workforce_Advancement_Marketing_Comm__c", @Workforce_Advancement_Marketing_Comm__c)
       EndIf
      EndIf

      If @Action == "UnsubscribeAll" THEN
        If (Substring(@SubscriberKey,1,3) == "00Q") Then
            set @result = UpdateSingleSalesforceObject('Lead',@SubscriberKey,'HasOptedOutOfEmail',1, "Student_Communications__c", 0, "Emeritus_Communication__c", 0, "Student_Newsletter__c", 0, "Community_Marketing_Communications__c", 0, "Workforce_Advancement_Marketing_Comm__c", 0)
        EndIf

        If (Substring(@SubscriberKey,1,3) == "003") Then
            set @result = UpdateSingleSalesforceObject('Contact',@SubscriberKey,'HasOptedOutOfEmail',1, "Student_Communications__c", 0, "Emeritus_Communication__c", 0, "Student_Newsletter__c", 0, "Community_Marketing_Communications__c", 0, "Workforce_Advancement_Marketing_Comm__c", 0)
        EndIf

Would appreciate any insight to be sure my users can unsub as needed.

2 Answers 2

1

I am assuming by "JSON" you mean a cloudpage of type JSON. There is very little JSON for us to see here :D

Error number 1:

You wrote RequestParmaeter where you should be writing RequestParameter.

Honest strategy: copy/paste more, type less.

3
  • 2
    @jdblundell, as Jonas said it’s best to copy and paste function and variable names to avoid mistakes like this. You could also use the ampscript.io editor to check the syntax, it would have caught this typo as well. Good luck with learning AMPscript!
    – zuzannamj
    Commented Sep 1, 2022 at 9:32
  • great catch!! Thank you both!
    – jdblundell
    Commented Sep 1, 2022 at 23:33
  • Also bookmarking the ampscript.io site. I tried a JSON validator and it didn't catch anything.
    – jdblundell
    Commented Sep 1, 2022 at 23:36
0

It was the typo. I figured it was something goofy on my part. That fixed it.

You must log in to answer this question.

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