Custom Search and Group

TL; DR: why are group offers disabled in the search when the field using the search is not empty?

I want to do a custom search on a field in a form. The CTable table looks like this:

 Val Spec ------------ A alpha A beta A gamma B delta C epsilon 

The search applies only to the Val column, which is determined using the EDT with a basic relation on it: Val == CTable.Val

The search obviously gives me a list like this:

 A A A B C 

Let the group to get rid of all duplicated As, I thought! Sort of:

 QueryBuildDataSource.orderMode(OrderMode::GroupBy); QueryBuildDataSource.addGroupByField(fieldNum(CTable, Val)); 

Now we get the strange behavior that I have, and the actual point of my question. In an empty field, the command runs correctly, and I get the following:

 A B C 

Now select “A” in the search, and then search again because I wanted to press “B” instead. Now the group is disconnected for unknown reasons, and I get the same search results as before.

Why is that? How can I overcome this?

+6
source share
3 answers

The same question and helpful answer: http://dynamicsuser.net/forums/t/63438.aspx

You can disable this behavior by setting the useLookupValues ​​parameter in SysTableLookup to false. Unfortunately, I do not know exactly why AX does this. I suspect it is changing OrderMode to OrderBy.

+5
source

I had the same problem yesterday.

I assume this code is in "init", maybe?

 QueryBuildDataSource.orderMode(OrderMode::GroupBy); QueryBuildDataSource.addGroupByField(fieldNum(CTable, Val)); 

I had to add the “GroupBy” code (see above) to the executeQuery method because the next line removed groupBys from my query (I checked this with breakpoints);

 qbsSum.sortClear(); 

If you use breakpoints, I would expect your GroupBy parameters to be cleared before the request is executed again.

+2
source

I had the same problem. It helps me:
sysTableLookup.parmUseLookupValue(False);

+1
source

Source: https://habr.com/ru/post/920329/


All Articles