I have a html web form which have input fields in it and when a customer fills in the form and clicks on submit, i want the input values to be taken into some data extension in marketing cloud [Marketing cloud and salesforce are connected using marketing cloud connector] and further i want the values to be created as a record inside salesforce using AMPSCRIPT..Is it possible and how?

1 Answer 1


Assuming that your 'html web form' is a CloudPage or Landing Page, then you can easily achieve this using AMPscript. Refer to sample code below.

Replace Account with the SF Object that you are creating records in, and MyDataExtensionName with the name of your Data Extension (and update the fields accordingly).

When the form is submitted using my code example, a confirmation message is displayed on the page.

This should be enough to get you started!

<html lang="en">


var @email, @firstName, @lastName, @createSfRecord, @createDeRecord

set @firstName = RequestParameter('firstName')
set @lastName = RequestParameter('lastName')
set @email = RequestParameter('email')

if RequestParameter("submitted") == "submitted" then

   set @createSfRecord = CreateSalesforceObject(
    'Account', 3,
    'FirstName', @firstName,
    'LastName', @lastName,
    'Email', @email)

   set @createDeRecord = InsertDE(
    'First Name',@firstName,
    'Last Name',@lastName,


<form action="%%=RequestParameter('PAGEURL')=%%" method="post">
<label>First Name</label>
<input type="text" name="firstName">

<label>Last Name</label>
<input type="text" name="lastName">

<input type="text" name="email">

<input id="submitted" type="hidden" name="submitted" value="submitted" />

<input type="submit" value="Submit">

%%=IIF(RequestParameter("submitted") == "submitted", '<p>Your form has been submitted.</p>','')=%%

  • Thank you :) In the Form tag, which page url must be given? and why is that for? Can you briefly say me
    – Priya
    Aug 22, 2016 at 9:34
  • The page posts back to itself. The RequestParameter('PAGEURL') function reloads the page when the form is submitted, posting the form parameters to back the page, which are then retrieved by the RequestParameter() functions. Note that I included a hidden submitted field, and if this is value present (which it would be after form submit), then this indicates that the form has been submitted and the if RequestParameter("submitted")... condition then creates a record in the SF Object and Data Extension. Similarly , the IIF() function displays a confirmation message on the page. Aug 22, 2016 at 10:07
  • Hi @Priya, did I answer your question? I tested the code before posting, so it should work for you. But let me know if you have issues. Aug 22, 2016 at 16:58
  • Hi @Eliot Harper .. In RequestParameter('PAGEURL') i have given the Cloud page url of the same code and the page is getting executed when i paste the url into a browser but when i click on submit after entering firstname,lastname and email, i get 500 - Internal Server Error(Couldnt Figure out why?)
    – Priya
    Aug 23, 2016 at 3:41
  • Hello Priya, you shouldn't need to replace RequestParameter('PAGEURL') with the URL, just use the code that I supplied. If you still have issues, then the first thing I would do is either comment out or remove the code from if RequestParameter... to endif. My guess is that you haven't created the required fields in the DE or you are missing some required fields in your SF Accounts object. Aug 23, 2016 at 3:45

You must log in to answer this question.

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