Adding QueryRange to datasource table

Dears,

Hope every one doing well,

I want to retrieve all the active positions from e.g PositionTable, and add some ranges to it, in this table every position is linked to an organization.

I want to retrieve all positions with other organizations but only specified employee’s from organization (10) for example those employees whose positongroup is (aboveManger) will come from the organization (10) but from other organizations rest of them. how should I do it?

Here is my code:

Query query;

PositionId positionId;

QueryBuildDataSource qbds1,qbds2;

;

query=new query();

qbds1 = query.addDataSource(tablenum(PositionTable));

qbds2 = qbds1.addDataSource(tableNum(PositionTable));

qbds2.relations(false);

qbds2.joinMode(JoinMode::ExistsJoin);

qbds2.addLink(fieldnum(PositionTable,PositionId),fieldnum(PositionTable,ReportsToPosition));

qbds1.addRange(fieldnum(PositionTable,ValidFromDateTime)).value(QueryRange(DateNull(),SystemDateGet()));

qbds1.addRange(fieldnum(PositionTable,ValidToDateTime)).value(QueryRange(SystemDateGet(),DateNull()));

qbds2.addRange(fieldnum(PositionTable,ValidFromDateTime)).value(QueryRange(DateNull(),SystemDateGet()));

qbds2.addRange(fieldnum(PositionTable,ValidToDateTime)).value(QueryRange(SystemDateGet(),DateNull()));

I did the scenario like bellow but it is not working:

qbds2.addRange(fieldnum(PositionTable,OrganizationUnitId)).value(strFmt(’((%1.%2 == %5) && (%1.%3 == %4))’,
query.dataSourceTable(tableNum(PositionTable)).name(),
fieldStr(PositionTable, OrganizationUnitId),
fieldStr(PositionTable,EmployeeGroup),
any2int(PositonGroup ::MaangerAbvoe),10));

Thanks in advance!

What “is not working” exactly means? Do you get any error? If not, how the constructed SQL string differs from the expected SQL string?

Can you reproduce the problem on a standard table, so we can copy your code and run it?

Dear Martin Dráb,

Thanks for your reply,

I get solved the problem by using AOT Query as bellow:

Queering PositionTable for rest of the organizations without organization (10), then queering the PositionTable only for the organization (10) for specified ranges, later on I applied Union All to the results and it worked.

Once again thanks from your reply,