is there any way to insert a salesforce record upon clicking of submit in smart capture form for cloud pages.

This are the following approach that I'm thinking of but I'm not sure if they're possible.

1.) I have a validation for my smart capture form field via , Is it possible to add SSJS inside this script so if all is valid I can just do a SSJS to insert salesforce record?

2.) Pass a primary key to the thank you cloud page. So upon clicking of submit it will be redirected to a thank you page from there I can use the primary key to get values from to the dataextension and insert in salescloud with ampscript

Any recommendation would be swell.


1 Answer 1


You can't add SSJS into validation script, as it is executed in the front-end only. I would very much recommend moving away from Smart Capture and build a custom solution, which will use Ampscript function of CreateSalesforceObject before upserting the form data to a data extension. This way you ensure you can store the field values with a reference to e.g. Contact ID from Sales Cloud, which is returned by CreateSalesforceObject function.

All fields submitted in the form are easily referenced using RequestParameter function. Ensuring CreateSalesforceObject is called before you upsert data to a Data Extension will also help with deduplication, as if a Contact with the provided email address already exists, the ID of this Contact is returned, instead of creating a new record.

You can find a good example of code behind such approach on zuzannamj's site: https://sfmarketing.cloud/2019/09/22/create-a-sales-service-cloud-integrated-lead-capture-form-using-ampscript/


You must log in to answer this question.

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