0

I have a cloudpage that is having a form and when I click submit it should have my details saved on the data extension and proceed to the confirmation page

set @prospectsDE = 'Prospects'
      
/* UPDATE Record to SF Object or DE(for Prospects) */
 
 /* For Contact */
 IF @object =="Contact" THEN
  set @updateobject = UpdateSingleSalesforceObject(@object,@subsid,
      "FirstName", @firstname,
      "LastName", @lastname,
      "I_Am_A__c", @i_am_a,
      "Healthcare_Setting__c", @health_care)  

 /* For Lead */
 ELSEIF @object =="Lead" THEN
    /* IF company value is empty */
  IF EMPTY(@company) THEN
      set @updateobject = UpdateSingleSalesforceObject(@object,@subsid,
      "FirstName", @firstname,
      "LastName", @lastname, 
      "Email", @email,     
      "Country", @country,
      "State", @state ,
      "I_Am_A__c", @i_am_a,
      "Healthcare_Setting__c", @health_care,
      "T_Cs_Accepted__c", @t_cs_accepted) 
     
   ELSE 
   
    set @updateobject = UpdateSingleSalesforceObject(@object,@subsid,
      "FirstName", @firstname,
      "LastName", @lastname,
      "Email", @email,
      "Company", @company ,
      "Country", @country,
      "State", @state ,
      "I_Am_A__c", @i_am_a,
      "Healthcare_Setting__c", @health_care ,
      "T_Cs_Accepted__c", @t_cs_accepted) 
   


   ENDIF

 /* For Prospects */
  ELSEIF @object =="Prospect" THEN

  SET @updateProspectDE = UpdateDE(@prospectsDE,1,
      'SubscriberKey', @subsid, 
      "First_Name", @firstname, 
     "Last_Name", @lastname, 
     "Email", @email, 
     "Company", @company, 
     "Country", @country, 
     "State", @state,     
     "Healthcare_Setting", @health_care,     
     "Subscriber_Type", @i_am_a, 
     "T_Cs_Accepted", @t_cs_accepted)     
      
  
 /* For New */
  ElSE
     set @insertProspectDE = InsertDE(@prospectsDE,
      'SubscriberKey', @subsid, 
      "First_Name", @firstname, 
      "Last_Name", @lastname, 
      "Email", @email, 
      "Company", @company, 
      "Country", @country, 
      "State", @state,     
      "Healthcare_Setting", @health_care,     
      "Subscriber_Type", @i_am_a, 
      "T_Cs_Accepted", @t_cs_accepted)
ENDIF

--

The page is perfectly fine when I run it but the problem is I am getting this error upon submitting the form

"This page isn’t workingcloud.info.aroa.com is currently unable to handle this request. HTTP ERROR 500"


Upon investigating whenever I remove this code

 /* For New */
  ElSE
     set @insertProspectDE = InsertDE(@prospectsDE,
      'SubscriberKey', @subsid, 
      "First_Name", @firstname, 
      "Last_Name", @lastname, 
      "Email", @email, 
      "Company", @company, 
      "Country", @country, 
      "State", @state,     
      "Healthcare_Setting", @health_care,     
      "Subscriber_Type", @i_am_a, 
      "T_Cs_Accepted", @t_cs_accepted)

It run perfectly fine and when I submit I get redirected to thank you page..

Upon digging Ive tried to change the DATA EXTENSION to other data extension so from "PROSPECTS" to prospects clone data extension and I wasnt able to have error when I do this

My question is whats wrong with "PROSPECTS" data extension wherein it is only the same thing of the clone data extension? Why am I having an error?

1 Answer 1

0

I don't think there is anything wrong with your Data Extension. But if you check the documentation on InsertDE function, you will find that it only works in emails:

This function applies to email messages at send time only.

Instead, you should use InsertData, which has exactly the same syntax:

InsertData('SomeDE','FirstName',FirstName,'LastName',LastName,'CreatedDate',NOW())

Use this function with landing pages, SMS and MMS messages in MobileConnect, push messages in MobilePush, and messages in GroupConnect.

The issue with InsertDE and InsertData is, that it only INSERTS a record. As you are trying to insert the same record twice (submitting same data in two request), it will fail, as a record with this primary key already exists.

You will need to replace your InsertData with UpsertData function. It will insert a new record, or update an existing record, based on the primary key of your data extension.

2
  • I have tried using this but it's not working too.. I have tried to change the DE and it works I am not sure whats the problem with the old one
    – Rain
    Commented Sep 29, 2023 at 8:25
  • @Rain - I have updated the solution Commented Sep 29, 2023 at 11:50

You must log in to answer this question.

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