0

Here is my code that executes after a submit button is pressed on a cloudpage

%%[UpsertData("SubscribersTester", 1, "Email Address", @subKey, "First Name", @Fname, "Last Name", @Lname, 
     "Monthly", @Monthly, "Weekly", @Weekly, "Volunteer", @Volunteer, "Account Status", @Status, "Date Modified", NOW()) ]%%

  %%[SET @updateSub = CreateObject("Subscriber")]%%
  %%[SetObjectProperty(@updateSub,"Email Address", @subKey)]%%
  %%[SetObjectProperty(@updateSub,"Subscriber Key", @subKey)]%%
  %%[SET @client = CreateObject("ClientID")]%%
  %%[SetObjectProperty(@client, "ID", @memberID)]%%
  %%[SetObjectProperty(@client, "IDSpecified", "true")]%%
  %%[SetObjectProperty(@updateSub, "Client", @client)]%%
  %%[SetObjectProperty(@updateSub,"Status","Active")]%%
  %%[SET @saveOptions = CreateObject("SaveOption")]%%
  %%[SET @updateOptions = CreateObject("UpdateOptions")]%%
  %%[SetObjectProperty(@saveOptions,"SaveAction","UpdateAdd")]%%
  %%[SetObjectProperty(@saveOptions,"PropertyName","Status")]%%
  %%[AddObjectArrayItem(@updateOptions,"SaveOptions", @saveOptions)]%%
  %%[SET @updateObj = InvokeUpdate(@updateSub, @updateStatusMessage, @updateErrorCode, @updateOptions) ]%%

When it runs it hits me with a 500. What am I doing wrong?

1

You may not be showing the entire code but you have not defined the variable for @subkey or @memberId. See the example here for using AMPscript on a custom preference page.

%%[

  /* Get the Id of the account */
  Set @mid = [memberid]
  /* Get the key from the form */
  Set @subKey = [_subscriberkey]

  if Empty(@subKey) or  @subKey == "" then
   SET @subKey = "subkey@example.com"
  endif

]%%
  • Yes I have those variables already initialized way up at the top of the page. But is the 500 code always just a non existent variable being called? – DaveFroop Jun 24 '19 at 19:01
  • Not always. It could a lot of things. – Jackson Chen Jun 24 '19 at 19:09
  • Is there a problem with how the calls are constructed though? The whole page is 300+ lines of code and that would be way too much to ask people go through for me. – DaveFroop Jun 24 '19 at 19:32
  • You may have to troubleshoot it line by line. It could be the UpsertData -- data columns could have the wrong data types or wrong column names being used. Also you don't need to wrap every line in a %%[ ]%%. Put the entire code in the block. Start off with AMPscript 101 and move your way up: developer.salesforce.com/docs/… – Jackson Chen Jun 24 '19 at 19:36
  • Do the columns have to be in the same order from as the list? – DaveFroop Jun 24 '19 at 19:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.