So you need to import entries from a CSV file based on certain criteria? That’s where conditional logic comes in!
Conditional logic is a powerful yet underrated feature of Gravity Forms. You can use it inside notifications, confirmations, and form fields to create a personalized user experience and simplify the way users interact with your website.
But that’s not all.
In this post, we’ll show you how to use the conditional import feature to import entries into Gravity Forms from a CSV file and filter them based on specific conditions.
What Is Conditional Logic in?
Conditional logic refers to a way of making decisions based on certain parameters, or constraints. It’s a process that says “if X, do Y”. Conditional logic functions in a similar way to “if” statements in programming.
How Does Conditional Logic Work for Imports?
When it comes to importing entries (or WooCommerce products), conditional logic gives you granular control by allowing you to filter entries based on certain criteria. For example, let’s say you have a CSV file containing 1,000 entries, but you only want to import the ones where the user’s Email Address ends with “@example.com”.
Without conditional logic, there would be no way to do this that didn’t involve a lot of manual work. When importing entries from a CSV file, conditional logic acts as a filter, allowing you to import entries that match certain criteria.
Gravity Forms: Importing a CSV Using Conditional Logic
To get started importing data into Gravity Forms, you’ll need to download and install the Import Entries add-on. Import Entries allows you to import entries from a CSV file, migrate your form data to from another form plugin, copy forms to a new website, and more.
Uploading Your CSV File
After installing and activating Import Entries, hover over Forms and click on Import/Export. Next, click on the Import Entries tab to open the Import screen. To upload your CSV file simply drag and drop it onto the screen.
Import Entries allows you to import data to an existing form or create a new form. Select the option that best suits you and click “Continue With Import”.
Mapping Fields
The next step is to map the columns in your CSV to the correct fields in Gravity Forms. You can do this by clicking on the Field Type dropdown and choosing the correct field in Gravity Forms.
When you’re finished mapping your fields, go to the next step by clicking “Continue With Import”.
Filtering Entries Using Conditional Logic
The final step of the import process is to configure the import options. Here you have the option to enable the Conditional Import feature. This allows you to import entries based on precise conditions.
Enabling the Conditional Import option will display the conditional logic settings. Here you’ll see several dropdown menus and a text input field. So what does all this mean? Let’s take a look at each setting in more detail.
- Choose whether to use AND or OR logic
If you select “any”, then only one of the conditions has to match. If you select “all”, then all the conditions have to match. This option is only applicable to cases where you have set more than one condition (we cover this in detail below). - Field
The field you want to filter on. - Parameter
Accepted parameters are is, is not, contains, less than, greater than. - Value
The value you want to compare the field value against.
In the example above, we’re using conditional logic to import all entries that contain “@example.com” in the “Email” field. In other words, if there’s an entry with the email address “[email protected]” it will be imported, but an entry with the email address “[email protected]” will not be imported.
There are several ways to utilize conditional logic when it comes to importing entries to Gravity Forms, so let’s go through some examples 🧐
Example #1
In this example, we’ve got a CSV file containing the names and contact details of all our company’s employees but we only want to import employees whose employee ID numbers are greater than 14.
Example #2
Here’s an example where we’ve set up an event registration form and we need to migrate all the registrations to a new website. However, we’re only interested in those where the number of attendees is fewer than 4.
Example #3
In this example, we’re importing product listings into Gravity Forms but we want to exclude all products in the “Electronics” category.
Example #4
Here we’re migrating product orders to a new site but we don’t want orders that are still pending to be included in the import. So, we’ve set up a condition to check the order’s status and only import it if it’s marked as “Completed”.
Setting Multiple Conditions
If you want to set up multiple conditions, you can do so by clicking on the ‘+’ button on the right. This allows you to configure a more sophisticated filter.
The dropdown menu at the top gives you two options – “any” and “all”. By selecting “all” the importer will only import entries that match all conditions. If you select “any”, the importer will import entries that match at least one of the conditions.
In the example above, we have a CSV containing event registrations, but we only want to import entries where the guests have confirmed AND the number of attendees is less than 4.
Using OR Logic (“any”)
In this example, we have a CSV containing property listings that we need to import into Gravity Forms. However, we only want to import listings that are located in EITHER New York or Boston.
Example With Three Conditions:
In this example, we’re importing a CSV containing property listings but we’re only interested in importing houses that are for sale in Chicago.
Hopefully, these examples have given you some clarity regarding the conditional import feature.
Gravity Forms Conditional Import From a CSV
In this post, we showed you how to import entries into Gravity Forms using conditional logic. When importing data using the Import Entries add-on, the conditional import feature gives you full control over your data.
Use the conditional import settings to filter out the entries you don’t need and save time having to manually remove data from your CSV file. To create a more sophisticated filter, set multiple conditions using AND or OR logic.
To learn more about conditional logic in Gravity Forms read Gravity Forms Conditional Logic: The Ultimate Guide.
Join Our Newsletter!📧🙌
✅ Helpful Gravity Forms content straight to your inbox
✅ Be the first to hear about new updates and releases