Filter Detail by Field on Page

I have a process that creates multiple orders from an Opportunity.  The orders are separated by a service location field (due to pricing and installation).  I need to filter a detail on the Order page by the service location on the order.  I tried using the filterMethod that I saw in an example, but it either doesn't filter or there is nothing returned at all.  Can anyone spot what I am doing wrong?

            "OpportunityProductDetailV2bd737a92": {
                "schemaName": "OpportunityProductDetailV2",
                "entitySchemaName": "OpportunityProductInterest",
                "filter": {
                    "detailColumn": "Opportunity",
                    "masterColumn": "Opportunity"
                }
                "filterMethod": "productLocationFilter"
            }

 

		methods: {
			productLocationFilter: function(){
				var filterGroup = new Terrasoft.createFilterGroup();
				filterGroup.logicalOperation = Terrasoft.LogicalOperatorType.AND;
				var recordId = this.get("[Opportunity].Id");
				//var orderId = this.get("Id");
				//var serviceLocationForOrder = this.get("AtsServiceLocation").value;
				var esqOpportunity = Ext.create("Terrasoft.EntitySchemaQuery", {
					rootSchemaName: "OpportunityProductInterest"	
				});
				esqOpportunity.addColumn("Opportunity");
				esqOpportunity.addColumn("AtsLocation.AtsAccAddress", "AtsAccAddress");
				var oppFilter = esqOpportunity.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Id", recordId);
				var OppId = "";
				var LocationId = "";
				esqOpportunity.filters.add(oppFilter);
				esqOpportunity.getEntityCollection(function(result) {
					//var respString = "";
					result.collection.each(function (item) {
						//respString += "ItemID: " + item.get("Opportunity").value + ";";
						OppId = item.get("Opportunity").value;
						LocationId = item.get("AtsAccAddress").value;
					});
					//window.alert(OppId + ", " + LocationId + ";" + serviceLocationForOrder + "~" + orderId);	
				},  this);
 
				filterGroup.add("OpportunityFilter", 
					Terrasoft.createColumnFilterWithParameter(
						Terrasoft.ComparisonType.EQUAL, "Opportunity", OppId));
				//var locationId = this.get("AtsLocation");
				filterGroup.add("LocationFilter", 
					Terrasoft.createColumnFilterWithParameter(
						Terrasoft.ComparisonType.EQUAL, "AtsLocation", LocationId));
				//filterGroup.add("ServiceLocationFilter",
					//this.Terrasoft.createColumnFilterWithParameter(
						//this.Terrasoft.ComparisonType.EQUAL, "[Order.AtsServiceLocation].Id", serviceLocationForOrder));
				return filterGroup;
			}
		}

 

Like 0

Like

3 comments

Hi,

I guess the problem is in your asynchronous code. You cannot use your OpportunityId and AtsAccAddress values from esq callback in your filter since it is asynchronous - it is being called after your filter return is already finished.

Dmitriy.

Hello Timothy,



Please note on the Dmitry comment, so you should transform your code to the linear structure. 



Also check the links with examples:

https://community.bpmonline.com/articles/filtering-details-several-fiel…



https://academy.bpmonline.com/documents/technic-sdk/7-13/using-filtrati…



Best regards,

Alex

I saw that documentation yesterday, but I thought it was from the perspective of the detail instead of the page.  It is working now.  My solution is pasted below for anyone that needs it.  Thanks for the help!

methods: {
	productLocationFilter: function(response){
		var filterGroup = new Terrasoft.createFilterGroup();
		filterGroup.logicalOperation = Terrasoft.LogicalOperatorType.AND;
		var OppId = this.get("Opportunity").value;
		var acServiceLocationId = this.get("AtsServiceLocation").value;
		//window.alert("OppId" + OppId + ", " + "acServiceLocationId" + acServiceLocationId);
		filterGroup.add("OpportunityFilter", 
			Terrasoft.createColumnFilterWithParameter(
				Terrasoft.ComparisonType.EQUAL, "Opportunity", OppId));
		filterGroup.add("LocationFilter", 
			Terrasoft.createColumnFilterWithParameter(
				Terrasoft.ComparisonType.EQUAL, "AtsLocation.AtsAccAddress", acServiceLocationId));
		return filterGroup;
	}
}

 

Show all comments