Onit Documentation

Creating Dynamic Filters for BelongsTo Fields

by David Goldfarb Updated on

BelongsTo fields allow you to set up a relation between a Record and some parent Record. There may be cases where you want to filter which parents are available to put in place for a child, and base that filter on data in the child Record. In this tutorial we'll show you how to do that.

Before We Start ...

This tutorial will assume you understand the following concepts:

An Example Use Case

Let's suppose that when you create a legal matter in your Matters app, that you want to relate your matters to legal entities. The set of available legal entities to bill to will be different for different matters. In our example we will imagine that some matters relate to real estate deals, and the rest don't. So we will note this with a Combo Field named "expense_type" with values "Deal" and "Non-Deal".

Meanwhile, in our Legal Entities app we will have a text field called "expense_type_eligibility", and for each Record we will likewise populate it with "Deal" or "Non-Deal".

Let's Get Started!

1. Create a Raw Transaction Filter

BelongsTo Fields have a control where you can set a filter in them.

This doesn't always need to depend on other Fields in your launch form: for example, you could set a filter in User Profiles to exclude people who are set as out-of-office.

In this case we are going to create a Raw Transaction Filter in Legal Entities which filters by our Field "Expense Type Eligibility".  If we were simply to filter for "deal", that would look like this:

[{"property":"p_expense_type_eligibility","operator":"like","value":"deal","type":"string"}]

For our purpose we don't want to filter by a hard-coded value: we want to use the value of a field in the Matter app. Fortunately, we can incorporate Liquid into our raw transaction filter. We replace "deal" here, with Liquid that outputs the value of our field from the Matter app to look like this:

[{"property":"p_expense_type_eligibility","operator":"like","value":"{{ expense_type }}","type":"string"}]

So we'll go to the Designer of Legal Entities, and in the Filters node that's what we'll put.

2. Configure the BelongsTo Field to use the filter

Now we go to the Wizard in the Matter app, and fill in the filter we just created in the BelongsTo Filter control on our BelongsTo Field.

3. Enter the Field name(s) to use in "Fields used to filter belongs to selection"

Further down in the Field configuration form, there's a control called "Fields used to filter belongs to selection". This is where we tell the system which fields to make available to the Liquid in the filter.

4. Try it out

Now we can launch a new matter, and set the Expense Type, and see how our Legal Entity options available are filtered down.

More complex configurations

The example above uses only one field to filter on. You are not limited to only one.  The "Fields used" control can accept a comma-separated list of field names. And likewise your Raw Transaction Filter can have more than one set of filters: just add more array items, separated with a comma.

As a simple example, suppose you have a field billing_date which tells you when a vendor has last submitted an invoice, and you want to filter down your vendors to ones that are active: i.e., that have a billing date value in 2022 or later. You could add that to our filter from above, and you'd get this:

[{"property":"p_expense_type_eligibility","operator":"like","value":"{{ expense_type }}","type":"string"},{ "property": "p_billing_date", "operator": "gt", "value": "1/1/2022", "type": "date" }]

If you set up a filter using two or more Fields from the launch form, the filter will use only those Fields that have data. A blank Field won't reduce the list of results to nothing.

Previous Article How to create a Cascading Listcombo (CLC)
Next Article Using Fields to Watch

© 2024 Onit, Inc.

docs.onit.com contains proprietary and confidential information owned by Onit, Inc. that is subject to copyright. Onit presents it exclusively to you for your sole use in conjunction with using Onit products. No portion of the materials contained herein may be used for any other purpose. No portion of the materials contained herein may be shared with third parties or reproduced in any form.