How to create a query range that searches two different fields

The 'OR' in a query is a little bit more complex the for example the 'AND', but it's not impossible.

The following code should do the trick:

q = new Query();

qbds = q.addDataSource(tablenum(DirPartyTable));

qbr = qbds.addRange(fieldnum(DirPartyTable, recId));

qbr.value(strfmt('("%1" == %2.%3) || ("%1" == %2.%4)',

name,

qbds.name(),

fieldstr(DirPartyTable, firstName),

fieldstr(DirPartyTable, lastName)));

I just use the DirPartyTable as example. name is the argument that is passed to function.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.