Lookup filtering with distinct values

Hi there,

 

Based on the account and contact lookup I have to filter Product lookup which is working fine.

 

But I can see the same product(Battery Back-up.....) two times, because more than one record has the same account and contact in the other section.

 

But I want to show it only one time. Attaching the screenshot.

 

Code : 

 

Like 0

Like

3 comments

Hi Akshit,

 

I've tried the code you've sent and unfortunately it didn't work on my end. But here is an example of my custom code that worked perfectly:

 

attributes: {
			"UsrProduct":{
				"dataValueType":Terrasoft.DataValueType.LOOKUP,
				"lookupListConfig": {
					"filters": [
					function() {
						var filterGroup = Ext.create("Terrasoft.FilterGroup");
						filterGroup.add("AccountFilter",Terrasoft.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL,
						"[Account:Id:UsrAccount].Name",
						this.get("UsrAccount").displayValue));
						filterGroup.add("ContactFilter",Terrasoft.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL,
						"[Contact:Id:UsrContact].Name",
						this.get("UsrContact").displayValue));
						return filterGroup;
					}
					]
				}
			}
		},

I have a Product section where I can select an account and a contact for the product and I've created a "Test section" section where the "UsrProduct" column represents the Product section. As a result I receive this result in this lookup:

since there are only two products in the products section that have "Our company" specified as an account and "123" specified as a contact:

As for using the DISTINCT statement - it's way more better to have products being connected to one contact and one account per one product since it reduces the possibility that incorrect product is chosen in the lookup.

 

Best regards,

Oscar

Hi Oscar,

 

Thanks for your response, below is my case

 

I have to perfrom filtration in section A , product(is a lookup on section B) column based on the selection of Account and contact. 

In section B, I have Account, contact and product (is a lookup on Product section).

Using BP I am updating the name column in section B from the product selected. The case is that there will be more than one record where I can have same account, contact and product selected in section B as you can see [A-B-C] in the screenshot. 

In this case, In section A if I select A as account, B as contact then I got C two times.

 

Hope you got the scenario. 

 

Regards

 

Akshit.

Akshit,

 

You will need to use esq instead where distinct can be used in filtration like in the example below:

esq.isDistinct = true;
esq.addColumn("UsrCandidatesId");

Please create such a filtration you've performed using filter groups, but using esq instead.

 

Best regards,

Oscar

Show all comments