Question

ESQ filters combinations

Hi Community!

How are you?

I hope you can help me!

 

I want to make a query with filters where the equivalent in sql server for example would be: "..Where field = 'Administrator' OR  field like 'Ope%' or field like 'Supe%'

 

 

Is there any way to include combinations of AND and OR with ESQ? Is there an alternative?

King regards,

Ezequiel

Like 0

Like

4 comments

Dear Ezequiel,

You can create the filter that would include AND and OR at the same time and would work as described. 

You need to build the filter as shown in the following example:

                var filters = Ext.create("Terrasoft.FilterGroup");
                filters.logicalOperation = this.Terrasoft.LogicalOperatorType.OR;
                filters.addItem(select.createColumnFilterWithParameter(Terrasoft.ComparisonType.START_WITH, "UsrPresents",
                               present.value));
                select.filters = filters;

 

Lisa

Hi Lisa! 

Thank you for you answer!

sorry, I expressed myself badly, I need to add a filter. The complete filter would be:

Where Id = 'some id' and (name = 'Administrator' OR  name like 'Ope%' or name like 'Supe%')

Can be done?

Regards,

Ezequiel

I show the example below

var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
				rootSchemaName: "SysUserInRole"
});
esq.addColumn("[SysFuncRoleInOrgRole:OrgRole:SysRole].FuncRole.Name", "RolFuncionaAsociado");
var esqFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "SysUser.Id", userId);
var esqFilter2 = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "[SysFuncRoleInOrgRole:OrgRole:SysRole].FuncRole.Name", nombreRol);

The second filter is who should have the OR combination

Regards,

Ezequiel

You can use my example above to create the correct filtration. Just make sure you add all the necessary filters to the collection and then combine them in the way you need. You can use the following example to add the filters to the collection:

// Adding created filters to query collection. 
esqCities.Filters.Add(esqFirstFilter);
esqCities.Filters.Add(esqSecondFilter);

More useful examples can be found in our Academy here - https://academy.bpmonline.com/documents/technic-sdk/7-11/use-entityschemaquery-creation-queries-database.

Lisa

Show all comments