
Like any data in Creatio, a detail list is based on an EntitySchemaQuery. Like any EntitySchemaQuery, you can add filters to limit the data. We can apply filters to the ESQ for a detail list as well so we can filter the results via code. For example, let’s say we have a detail that has items that represent actions a user needs to take and once complete we don’t want to see them in the list anymore, or date-based records that we don’t want showing once the date has passed. This is an easy task to accomplish.
When you add a detail to a page, there’s an entry added to the details section of the page. It looks something like this:
details: /**SCHEMA_DETAILS*/{ "UsrSchema02c75cecDetail9906b620": { "schemaName": "UsrSchema02c75cecDetail", "entitySchemaName": "UsrCurrentActions", "filter": { "detailColumn": "UsrAccount", "masterColumn": "Id" } } }
We’ll say that this detail is for an object named UsrCurrentAction that is related to an account and we have a boolean column named UsrComplete on the records in this detail. When this value is true, we no longer want the records to appear in our detail list. Our first step is to add a filterMethod to the detail section we saw above with the name of the function we’ll create to supply the filters. With the addition it will look like this:
details: /**SCHEMA_DETAILS*/{ "UsrSchema02c75cecDetail9906b620": { "schemaName": "UsrSchema02c75cecDetail", "entitySchemaName": "UsrCurrentAction", "filter": { "detailColumn": "UsrAccount", "masterColumn": "Id" }, "filterMethod": "getCurrentActionsFilter" } }
We’ve added a filter method named getCurrentActionsFilter, however, this can be named whatever we want. This will be the function name we’ll create that will return the filters for the detail. Note, at this point we could remove the “filter” property with detailColumn and masterColumn, if wanted (it doesn’t harm to leave them there, but they won’t be used anymore with the filterMethod present). When we add a detail to a page, we wire it up by selecting a master and detail column to match up. This is essentially creating a filter for us that tells the data how to link up to the page we’re on – so it shows the right data for the record. We are going to be replacing that with our own filter(s). This is important to understand because we’ll need to be sure to include this filter that relates the detail data to the parent record of the page we’re on as well. So, in the scenario of only showing data where our UsrComplete column is false, we’ll also need to include a filter where the account lookup on our detail object matches the current account’s Id. Our filter method will look like this:
getCurrentActionsFilter: function() { var filterGroup = new Terrasoft.createFilterGroup(); filterGroup.logicalOperation = Terrasoft.LogicalOperatorType.AND; // filter to link to current account filterGroup.add( "AccountFilter", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL, "UsrAccount", this.get("Id") ) ); // filter to only include where UsrComplete is false filterGroup.add( "NotCompleteFilter", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL, "UsrComplete", false ) ); return filterGroup; }
Now, with this code in place, if a record in our detail gets the UsrComplete column checked (set to true), it will disappear from our list.
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!