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.

 

 

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. Next, please open the PDF Editor for this specific form in one browser tab and the form builder page in another one.

 

 

7. From here you can copy the merge field IDs that will be used in a custom JavaScript code.

 

 

8. Please open the form builder tab, and drag & drop a JavaScript element on your form.

 

 

9. 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’]

 

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

 

 

11. 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

 

 


Feedback and Knowledge Base