I need to create a Landing Page Web Form in Marketing Cloud where once the user submit the form some REST API code will be executed to create some object records in SalesCloud (Contact + Asset + Attachment).

The user will be also able to upload a file (PDF or Image) that will be the attachment record content.

I am a beginner on using Javascript so I am not sure what is the best way to implement that.

Normally the server-side code will be executed when the page is being rendered but I am not sure if I could run some Server-Side Code after submitting the form (onSubmit, onClick, etc.) passing the variable values I need for creating the correspondant records in SalesCloud. (the uploaded file, user details, etc.)

I could also execute the REST API Calls to SalesCloud endpoints from client-side javascript code but I am not sure if this is a best practice.

Could you please advise me on how to implement this functionality ?

Thanks in advance, Enrique


1 Answer 1


If you are using the Marketing Cloud Connector, then you could accomplish this task fairly easily with ampscript. You'd need to take your user input with the form and, on the user clicking submit, direct the user to a processing page where you can capture the values they input and assign to variables using RequestParameter ampscript function.

Once you have that data captured in ampscript variables, then you can use the CreateSalesforceObject ampscript function to created your desired records within SF. Then, once this processing has been completed, redirect your user to the final display page letting them know the status of their submission.

The file upload portion will be a little tricky but you should be able to base64 encode the upload in order to pass that data for upload into SF.

If you are not using the MC Connector, then you are going to follow a very similar approach except that you will need to take that ampscript data, pass it to SSJS using the GetValue SSJS function and then make your API calls to SF to import the data using SSJS.

Also, do not ever pass customer data to SF (or any platform) on the client-side. That is a huge security vulnerability and is actually more difficult to implement than simply handling this on the server-side.

Updated To Include Snippets

Get Form Input On Processing Page w/ Ampscript

set @emailaddr = RequestParameter('emailaddr')

Pass Ampscript Variables To Server-Side Javascript

<script runat=server>
Platform.Load("Core", "1");
var address = Platform.Variable.GetValue('@emailaddr');

Sample POST Request Using Server-Side Javascript

<script runat=server>
Platform.Load("Core", "1");
var contentType = 'application/json';
var request = {"value":"test"};
var payload = Platform.Function.Stringify(request);
var headerNames = ["Authorization"];
var headerValues = ["Bearer " + YOUR AUTH TOKEN];
var result = HTTP.Post(url, contentType, payload, headerNames, headerValues);
  • Hi Jason, Thanks a lot for your comments. They are really very valuable information. Yes, I am using also Marketing Cloud Connector so I will create the Sales Cloud objects in this way. Thanks again ! Jun 25, 2019 at 14:17
  • Awesome! Glad that helped. Jun 25, 2019 at 14:18

You must log in to answer this question.

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