Filtering details by several fields

Question

How can I add filtering by a custom field to a detail? For example, the "Documents" detail in an opportunity does not display the opportunity specified in the document custom field. How can I fix this?

Answer

Here is an example of a filter by the "Opportunity" column and the manually created UsrOpop column for the [Documents] detail on the [Opportunities] section page. The code from the details property:

"Documentd03ac1374493": {
   "schemaName": "DocumentDetailV2",
   "entitySchemaName": "Document",
   "filterMethod": "relationshipDetailFilter",
   "filter": {
      "detailColumn": "Opportunity",
      "masterColumn": "Id"
   }
}

The code of  the relationshipDetailFilter() filtering method:

relationshipDetailFilter: function(){
    var recordId = this.get("Id");
    var filterGroup = new this.Terrasoft.createFilterGroup();
    filterGroup.logicalOperation = this.Terrasoft.LogicalOperatorType.OR;
    filterGroup.add("DocumentAFilter", this.Terrasoft.createColumnFilterWithParameter(
        this.Terrasoft.ComparisonType.EQUAL, "Opportunity", recordId));
    filterGroup.add("DocumentBFilter", this.Terrasoft.createColumnFilterWithParameter(
        this.Terrasoft.ComparisonType.EQUAL, "UsrOpop", recordId));
    return filterGroup;
}

 

Like 1

Like

Share

2 comments

How can i add combination of AND & OR Logical Operators here?

say like (Param>0 AND Type = '') OR (Param>0 AND Type = '') something like this.

 

Sriraksha KS,

The idea is to make firstly one filter group for AND clause. Then create second filter group for second AND clause. Afterwards, you create a filter group, which combines a first one AND, second AND and other clause. By default filters are added via AND.



Please feel free to use the example below. In the example the filter looks like: 

(CITY = 'Los Angeles' AND AddressType="Home")  OR  (CITY = 'London' AND AddressType="Home")



define("ContactPageV2", [], function() {

    return {

        entitySchemaName: "Contact",

        attributes: {},

        modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,

        details: /**SCHEMA_DETAILS*/{

                ContactAddress: {

                schemaName: "ContactAddressDetailV2",

                filter: {

                    masterColumn: "Id",

                    detailColumn: "Contact"

                },

                filterMethod : "complexFilter"

            },

        }/**SCHEMA_DETAILS*/,

        businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,

        methods: {

            complexFilter: function(){

            

                var recordId = this.get("Id");

                var filterGroup = new this.Terrasoft.createFilterGroup();

                filterGroup.logicalOperation = this.Terrasoft.LogicalOperatorType.OR;

                

               var filterAGroup = new this.Terrasoft.createFilterGroup();

                filterAGroup.logicalOperation = this.Terrasoft.LogicalOperatorType.AND;

                

                

                

                filterAGroup.add("LosAngFilter", this.Terrasoft.createColumnFilterWithParameter(

                    this.Terrasoft.ComparisonType.EQUAL, "City", "9AAF1EAA-F36B-1410-0099-00155D043204"));

                filterAGroup.add("Home1Filter", this.Terrasoft.createColumnFilterWithParameter(

                    this.Terrasoft.ComparisonType.EQUAL, "AddressType", "4F8B2D67-71D0-45FB-897E-CD4A308A97C0"));

                filterAGroup.add("Contact1Filter", this.Terrasoft.createColumnFilterWithParameter(

                    this.Terrasoft.ComparisonType.EQUAL, "Contact", recordId));

                

                var filterBGroup = new this.Terrasoft.createFilterGroup();

                filterBGroup.logicalOperation = this.Terrasoft.LogicalOperatorType.AND;

                

                filterBGroup.add("LondonFilter", this.Terrasoft.createColumnFilterWithParameter(

                    this.Terrasoft.ComparisonType.EQUAL, "City.Name", "London"));

                filterBGroup.add("HomeFilter", this.Terrasoft.createColumnFilterWithParameter(

                    this.Terrasoft.ComparisonType.EQUAL, "AddressType", "4F8B2D67-71D0-45FB-897E-CD4A308A97C0"));

                filterBGroup.add("ContactFilter", this.Terrasoft.createColumnFilterWithParameter(

                    this.Terrasoft.ComparisonType.EQUAL, "Contact", recordId));

                

                filterGroup.addItem(filterAGroup);

                filterGroup.addItem(filterBGroup);

                

                

                return filterGroup;

                

            }

        },

        dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,

        diff: /**SCHEMA_DIFF*/[

            

        ]/**SCHEMA_DIFF*/

    };

});



The result is here -> https://i.imgur.com/Z6LFEq3.png

Show all comments