Skip to content

Generate unique ID and send to Salesforce using the JavaScript element

In this guide, we will explain how to create a form workflow that will generate a unique ID and record it in a read-only text field. The text field will be mapped to the Object name field on Salesforce. Every Formyoula form entry will generate a unique ID that can also be used as a merge field on email and PDF templates.

We will start by creating a Read-Only Text Field on our form.

Screen Shot 2017-01-03 at 140556png

Next, please drag and drop a new JavaScript element on your form. This will hold the logic for unique ID generation and record the value in the read-only text field.

Screen Shot 2017-01-03 at 142230png

Please use the following example logic that generates a unique ID every time the form is started. Please change the 12 digit component ID to your Read Only text field. You can access the merge field ID on the PDF Editor.

//Check if value already exists

if( !$('#component-1c43-69fb-a185 input').val() ) {

 //Generate a new unique ID and save in read only text field

 $('#component-1c43-69fb-a185 input').val( 'My Unique ID: ' + Math.random() ).change();


Please save the form and map the Formyoula field to your Salesforce field.

Screen Shot 2017-01-03 at 142733png

Now every time you start a new form entry a unique ID will be generated and recorded in the read-only text field.

Screen Shot 2017-01-03 at 142455png

When you open Salesforce, you can see new accounts created with the unique ID.

For any questions, please contact us -

Feedback and Knowledge Base