How To: Display and Select Salesforce Opportunity Records Based on Multiple Criteria Search

Intro

In this blog post, we are going to expand upon a previous tutorial to look at how to implement multiple-criteria search of Salesforce records using FormAssembly. Implementing this search functionality makes locating the right record in Salesforce a much easier task for form respondents, and creates cleaner and better flowing forms.

In the example below, we’ll be working with the Opportunity object. Our two search criteria are the Opportunity name and its amount.

Note: this is somewhat advanced use of FormAssembly. If you’re not comfortable editing custom code, you might want to build up those skills before attempting this tutorial. Here is some information from our documentation to get you started. Please note that our Success Team does not support custom code help, however we do work with a number of partners who may be able to assist you, please email us at partners@formassembly.com.

Prerequisites

Before we start, we need to create three forms and give them names. For simplicity purposes the forms in this tutorial are called “Multiple-Criteria Search – Part 1/2/3”. Note: You’ll need to use the URL for form three in the setup for form two.

First Form Setup

The first form is just an interface to enter the criteria for our search. Go ahead and add two fields to the form as shown in the screenshot below:

Second Form Setup

For this form, we need a way to show the results of our search. We’ll do that by creating a repeatable fieldset with the records we get from Salesforce.

The first step is to create a new fieldset and make it repeatable. Recreate the following:

To create the “Select” hyperlink, follow these steps:

1. Add a new Text element on the page

2. Click on HTML in the menu above the new Text element:

3. Paste the following into the pop-up:

<a class=”htmlContent” href=”LINK”>Select</a>

4. Click “Save HTML” and “Done”

Once you are done with the Text field, navigate to Properties -> Custom Code and insert the following:

This will give us access to use jQuery framework, which makes manipulating HTML elements a lot easier.

Once we have jQuery available to us, add the following AFTER the previous script. Replace tfa_XXX with the alias of the ID field, YOUR_INSTANCE with your instance name and THIRD_FORM_URL with the URL of the form we’re about to create!

This code snippet will modify where each “select” link on the page takes us.

Third Form Setup

This setup is completely up to you! We’re only using this form to display the Opportunity information that users select in the second form.

Example:

Hint: Use the Salesforce Import Tool to speed up this process and automatically configure the Salesforce Connector.

Setting Up Connectors

There are no connectors on the first form.

For the second form, we are going to use the Salesforce Prefill Connector. (Learn more about our Salesforce Prefill Connector.) Once the Prefill Connector is created, we need to enable it and set it up.

The setup is very simple! Since we have two search terms, we need to pass them both to the connector.

Notice that we are using LIKE operator for the first parameter and GREATER THAN for the second.

Since we need a way to display multiple Opportunity records in a repeatable section, we need to setup the multiple records setting.

Lastly, we need to map the fields.

The third form will also have a simple Salesforce Prefill Connector. We are going to prefill the form based on the id of the record. Your mappings might vary here.

Passing Data Between Forms

Next we’ll be using form redirects to pass the search terms from the first form to the second.

3. Replace YOUR_INSTANCE with your instance name, SECOND_FORM_ID with the id of the second form, tfa_NAME with the opportunity name search term field and tfa_AMOUNT with the other field on the first form. Notice that we’re using %25 around the first parameter – that is because LIKE operator in Salesforce expects % around the term. We need to encode, hence %25 represents %.

4. Click Apply.

The Results

Once you’ve completed the setup, you should test your forms. The flow should go like so:

Enter a search term and a “greater than” figure for the amount field.

2. You should see all records that match those search terms displayed on the next form.

3. When you choose a record by clicking on Select, you should be taken to the third form.

4. The third form will show additional information about the selected opportunity.