Hello All,
i am just stuck with a requirement in smmActivities Form.
I know how to manually set a filter for a column and then this criteria is also displayed in the grid (so the user can change it).
But how to do this for the ResponsibleWorker field? This is a ReferenceGroup field. I can set a filter (see code below) but the user can’t change it (because it is not displayed in the corresponding grid).
When you use a replacement group, an outer-joined data source is added automatically to get the replacement data. That’s what you have to filter. And because it uses outer join, you can’t use simple range - you have to use a query filter. For example:
It’s displayed in query definition (Ctrl+F3), so users can change it. But I didn’t realized you asked for seeing it among grid filters. I’ll see if I can find a solution for that…
Actually, I tried my solution and it works - I see the value in grid column filter. Just ensure yourself that you filter by a field that is displayed in the grid. In my example, it means that you have to use a replacement group that contains PersonnelNumber.
If you want to filter by a field that doesn’t exist in the grid, you can’t use “Filter by grid”.
But: It is not displayed in the grid (Strg+G). I set the filter to “smmActivities.ResponsibleWorker” (RecId).
Because of the replacement group the value displayed comes from “DirPartyTable(DataSource1).Name”. But the DirPartyTable/DataSource1 is not part of the smmActivities-Form-DataSources …
So the question, how to set the value DirPartyTable(DataSource1).Name, or?
If you want to filter by RecId, the requirement makes little sense. You can’t expect users to fill Int64 values if they want to filter records. That’s why there are replacement values such as Name.
You don’t see the filter because the field you filter by (ResponsibleWorker) isn’t displayed there. Fields from the replacement group are displayed instead. You have to filter by fields displayed in the grid if you want to see filter in columns’ headers.
The data source is added automatically as runtime, as I already tried to explain in my first reply.
The implementation will be the same as what I already gave you, you just replace table and field names:
Exactly this is what i am trying to do. BUT: The Form (in the IDE) itself only contains the smmActivities.ResponsibleWorker Field (RecId). I know that the DirPartyTable is automatically added at runtime. The problem ist that “q.dataSourceTable(tableNum(DirPartyTable))” results null.
I try to implement the code in the init method from smmActivities DataSource (after super).
Your code runs when the root data source is being initialized . No other data source exists in the moment. You have to call your code later, e.g. in form’s init() after super().
Nevertheless I also didn’t realize that the data source you need is DirPerson, not DirTable. Now works for me exactly as required.
This is how the query in smmActiovities form look like - it should help you understand what’s going on:
SELECT FIRSTFAST * FROM smmActivities(smmActivities)
USING INDEX ActivityNumberIdx
OUTER JOIN Person, Person FROM HcmWorker(Ref_HcmWorker_ResponsibleWorker)
ON smmActivities.ResponsibleWorker = HcmWorker.RecId
OUTER JOIN Name, RecId FROM DirPerson(Ref_DirPerson_ResponsibleWorker_DirPerson_FK)
ON HcmWorker.Person = DirPerson.RecId
OUTER JOIN Person, Person FROM HcmWorker(Ref_HcmWorker_DoneByWorker)
ON smmActivities.DoneByWorker = HcmWorker.RecId
OUTER JOIN Name, RecId FROM DirPerson(Ref_DirPerson_DoneByWorker_DirPerson_FK)
ON HcmWorker.Person = DirPerson.RecId