Hi,
I am working on a scenario, when a user changes the value in account field in activities section a custom lookup ( say bank account no.) needs to be filtered based on a detail inside account section. This detail in account section has two lookups ( account and bank account no. ). But the custom lookup in the activities section has only the bank account no. in it.
As there is no direct relation between the two tables, I am not able to use simple filteration rule. Is there any way to get this sorted?
Thanks,
Halludeen.
Like
Hi,
you can use ESQ method to filter and bind it back to the fields.
Halludeen,
Please see the example of an ESQ with needed filtration. I hope I have understood the relation between sections and detail correctly.
setBankNo: function() { // getting Id of bank no. on Activity page var bankNo = this.get("UsrBankNo").value; if (bankNo) { var esq = Ext.create("Terrasoft.EntitySchemaQuery",{ // creating ESQ to detail object, which is on the Account page rootSchemaName: "UsrDetailObject", }); // we need two fields on detail: one to filter records by (bank no in our case. Other one we need value of to set on activity page. esq.addColumn("Account"); esq.addColumn("UsrBankNo"); var esqFilter = Terrasoft.createColumnFilterWithParameter( this.Terrasoft.ComparisonType.EQUAL,"BankNo",bankNo); esq.filters.add(esqFilter); esq.getEntityCollection(function(result){ result.collection.each(function (item) { // setting received account from detail to a variable var account = item.get("Account").value; }); }) // setting account to account field on activity this.set("Account", account); } }
In any case you can use this example and adjust it up to your business task.
Regards,
Anastasia
Hello Anastasia,
Thanks for the advise. But the requirement is in such a way that I cannot use ESQ to filter directly. The custom lookup is located in totally different section which doesn't have any relation to the lookup I am referring to.
Consider bank account no. lookup is located in activities section. The activities section also has account lookup. The bank account no. lookup has to get autopopulated depending on the account chosen in the activities edit page. The problem is, the account itself doesn't have this bank account information. It in turn has a detail which holds both account and bank account lookup mapping.
Once, I filter and retrieve the data in a collection, I am not able to filter only that particular values in the lookup.
Hope this explains the scenario.
Thanks,
Mohamed.
Halludeen,
The ESQ I have provided does cover your business task. The connection is built through account field. You enter the account on activity page. The same account is mentioned on the detail. Adjust the ESQ I have provided so to take account from activity page and filter by account detail object, retrieving bank account no from object, then apply it on activity.
If you will have difficulties, please descrivbe in what part of the method you have difficulties.
Regards,
Anastasia