[SalesForce] Upsert/Add to data extension using Smart Capture

Seems like a simple request but I can’t figure this out. Using Smart Capture forms, I’d like to update or add new records to a data extension. Adding new records works as expected, but if the record exists, the form will not submit.

I know this is possible using Web Collect and DEManager but I’d like to get this working with Smart Capture to be built using drag-and-drop components. I’ve tried adding hidden fields with no luck.

Salesforce documentation states this is possible but it’s not very clear how to configure. Any help is appreciated, thank you!

https://help.salesforce.com/articleView?id=mc_es_smart_capture_form_actions.htm&type=5

https://help.salesforce.com/articleView?id=mc_es_input_parameters_for_upsert_to_data_extension.htm&type=5

Best Answer

I don't think this is possible as Smart Capture forms seem to be "insert" only.

This leads to the behavior that the form in your case does not submit due to a primary Key Violation (inserting the same key twice is not allowed).

A workaround to keep the drag-and-drop functionality can be to remove all Primary Keys from the data extension behind the form. Basically, keep this data extension as "dumb" as possible in terms of validation to accept all kinds of user input.

For each record inserted, populate a date field ("timestamp") with a default value of "now" (getdate() ) to discern the latest entry and use backend processing via e.g. SQL to create a "clean" data extension without duplicates, by e.g. keeping the newest entry.

Then use the cleaned up DE for any further processes.

To address your followup questions:

Can SSJS/AMPscript be used to display a message on the page that a record already exists and has been updated?

Yes.

Send the user to the page using CloudpagesUrl AMPScript function: This establishes the "user context" on the cloudpage, meaning that the personalization string %%_subscriberkey%% will resolve to the user's subscriber key. From this you can basically get all the user's data.

AMPscript can be used to perform a Lookup into your Data extension and check if there is an existing record with e.g. the same subscriber Key or email. However, we are of course leaving point-and-click territory here ;)

Can the cleaned up de be used as the entry event into a journey?

Yes.

That is pretty much the idea. accept all data into a validation-less data extension. Validate in the backend and clean up your data. use the cleaned up DE as source for a Journey that e.g. sends validated Leads and Contacts to Salesforce.

Create the SQL query that performs the cleanup and save it in an automation.

Next, build your journey. Set the Journey to Entry source: Data extension. Select your cleaned up DE as that Data Extension.

Next, set as Entry Source Schedule: "Automation" Select your Automation built earlier. Finish building the Journey as you wish.

Once you activate your Journey, navigate to the automation referenced. You will see the activation placed a "diamond" style icon behind the last step of the automation, which represents the injection of its result into the Journey.

Related Topic