Example #3: Get Contact Details With Conditional Logic
In this example we will ask the user for a contact's last name and when he enters one and presses on the button -the contact's details will be populated from Salesforce into the section below (containing: Account name, Department, Phone, Email, Title).
In addition we will add a hidden field - which will be used to store the record_id, and we will add a condition to it saying that the account id must be at least 14 chars long.
Following are step by step instructions to populate the data from Salesforce with a condition:
1- | In order for this example to work you will need to make sure you have sample data in your Salesforce "contacts" object. Simply enter Salesforce, add a few contacts and make sure they all have: account name, department, phone,email and title. |
2- | Open the form builder and create a new blank form. |
3- | Drag a Textbox element and a Button element next to it. Change the textbox label text to: "Contact Last Name" (in "Properties panel" > "Element" tab > "Settings" option > Basic > Label) Change the button text to "Find Contact" and Button type to "dummy" - this means that the button doesn't really do anything, it is just a way to get the user to click outside of the textbox after entering a last name. |
4- |
Drag a "hidden" element and change its name to "contact_id" (in "Properties panel" > "Element" tab > "Settings" option > Name) The hidden element is not displayed in the form, it is only used to store data - in this case it is added to the form to store the contact id in it and add a condition to it. |
5- |
Drag a section element below the textbox and make it bigger, so that you can drag a few labels in it. |
6- |
Return to the Hidden element to configure the condition. Adding the condition is simple - just select the hidden element, go to its settings (in "Properties panel" > "Element" tab > "Settings" option > Conditioning ) and press on "Configure Conditions" to set the following rule: contact id minimum length must be 14. Press on the "Configure fields visibility" button (to define the result for the rule you have just created) and change the section element status "Show". This will make the section appear in the published form, only if the user fills in a contact last name that has more than 14 chars in its contact_id. |
7- |
Drag 2 labels and place them one above the other. Change the upper label text to "Account Name" (in "Properties panel" > "Element" tab > "Settings" option >Text) - we will use this as a simple regular label text. Change the Lower label text to "Account Name#" (in "Properties panel" > "Element" tab > "Settings" option >text) - we will populate the Account Name into this label. * It is recommended to make the lower label wider so the populated text will not break. To change its width simply select the label and pull its right handles to the right. You can also change width in the elements style settings (in "Properties panel" > "Element" tab > "Style" option >"Size & Position" category > width) |
8- |
Drag 2 more labels and place them one above the other. Change the upper label text to "Department" (in "Properties panel" > "Element" tab > "Settings" option >Text) - we will use this as a simple regular label text. Change the Lower label text to "Department #" (in "Properties panel" > "Element" tab > "Settings" option >text) - we will populate the department name into this label. * It is recommended to make the lower label wider so the populated text will not break. To change its width simply select the label and pull its right handles to the right. You can also change width in the elements style settings (in "Properties panel" > "Element" tab > "Style" option >"Size & Position" category > width) |
9- |
Drag labels for 3 other fields into the section: Phone, Email and Title. Do so in the same way as you did in bullets #6 and #7. |
10- |
Give the form a name (in "Properties panel" > "Form" tab > "Settings" option > "General" category > Form Name) Save the form (In the Upper toolbar) |
11- | Now that the form is created you will need to set up the "Get" integration: Go to "Properties panel" > "Form" tab > "Settings" option > "Salesforce Integration" category > Get From Salesforce Press on "Map fields" button - this will open the "Get" window, where you will need to configure the "Get" integration. |
11- |
First authenticate with Salesforce. |
12- |
Press on the "Add Object" button. Select the "contact" object from the dropdown. Press on the "Set conditions" button and set the following rule: Last Name equals contact last name. Turn on the "Set custom message" checkbox and enter text in case data is not found: "No contacts found". |
13- |
Map the following fields in the form to the salesforce fields: * Please note that in order to do the Mapping you will need to match the field ID with the field from Salesforce. Each element used in FormTitan form builder has its own Field ID which you can easily look up by selecting the field and checking its ID in the "Properties Panel" > "Element" > "Settings" > "Basic" > Field ID In order to find out which ID belongs to which field you will need to select each label. fld7 > Department, fld9 > Business phone, fld11 > Email, fld13 > Title and contact_id > Record ID This will draw all the contact details from your Salesforce account into the labels in the section, apart from the "Account Name" field, which we will map in the next step. Press on "Apply" |
14- |
Now you will see a line has been added to your integration window. On the left side you will see its number is "1" and its name is "Contact" (based on the object you chose) On the right side you will see 4 icons: Edit, Clone, Add and Delete. Pressing on the "Add" icon from a specific line will allow you to configure a line under it - in hierarchy. Press on the "Add" icon inside the first line to create a hierarchy. Since the "Account Name" is located under the account object (and not under contacts) we will need to draw it from there. Once the mapping window opens, simply select the "Account" object from the drop down. Set a condition: Record ID Equals #1 Contact (this is the object we chose in the first line) Now another dropdown will open under it: choose "Account ID" Press "Apply" |
15- | Map the salesforce remaining field: fld15 > Account Name This will draw all the account name into its label in the section. Press on "Apply" |
16- |
Now you will see that you have 2 lines in your "Get" integration window. Press "apply" and save the form. |
17- |
Publish the form as "url" to test it Enter a last name of an existing contact in the textbox and press on the button. You will then see your contact details drawn straight from Salesforce. |
Learn more about how to use "Get" from the following posts:
Salesforce Get Integration Example #1
Salesforce Get Integration Example #2