Skip to content

Custom Controlling Field Logic

In this guide, we will demonstrate how to use a Salesforce Lookup with a specific search value as a controlling field.

 If you have any questions, please email us support@formyoula.com.

 

1. Please edit your form template.

 

 

2. Please add a Salesforce Lookup and another field on your form (in this example we will use a checkbox field).

 

 

3. Please edit the checkbox field and click on the “Add Controlling Field” option.

 

 

4. Please select the Salesforce Lookup field as the “Controlling Field” and select “Yes” as the “Show if” value.

 

 

 

5. Please Save & Close the form.

 

 6. To get the merge field IDs that will be used in a custom JavaScript code, click on the pencil icon corresponding to the element and copy the merge field ID.


From Slitecom

7. Next, drag & drop a JavaScript element on your form.

 

 

8. Please edit the field and add the following code:

 

//Add a default controlling attributes in checkbox using form builder

//On lookup change

window.formyoula.form_fields['Lookup Field'].on('change', function(){

//If selected value  not matched with specified value

console.log(this.get("name"));

if(this.get("name") && this.get("name").indexOf("Edge Communications") === -1){

 //Set display no

 window.formyoula.form_fields['Checkbox'].get('controlling_elements')[0].value = "No"

}else{

//Else dispaly

 window.formyoula.form_fields['Checkbox'].get('controlling_elements')[0].value = "Yes"

}

//trigger change

window.formyoula.form_fields['Checkbox'].trigger('change');

})

 

 

 

Please change the records name from the “Edge Communications” to your prefered Record Name.

 

Also, please input your merge field ID values in the [‘Lookup field’] and [‘Checkbox’] code lines as in the following example:

 

  • From [‘Lookup field’] to [‘8df7-efe3-9db9’]

 

  • From [‘Checkbox’] to [‘61e4-91dc-5506’]

 

9. Once added, please Save & Close the form.

 

 

10. Now when you start a new form entry, the checkbox field will be hidden.

 

 

And the checkbox field will be displayed only if the correct Record Name (in this example case: Edge Communications) will be found via the Lookup field.

 

 

 

For any questions, please contact us - support@formyoula.com or the Formyoula in-app chat 🙂 

 


Feedback and Knowledge Base