We would like to implement filtering of one of our drop-down properties based on value selected in another property. To be bit more concrete, I will try to explain you our setup of object types and properties.
As described in many threads, we have object type Employee containing information of employee and a reference to M-Files User:
Employee
- Name
- MFileseUser -> reference to User object type
We have Policy object type containing information about policy and and the list of report reviewers for specific report type we have in our business case:
Policy
- Name
- XY_Report_Reviewers -> list of Employees who should have access to review specific policy
Both object types are correctly mapped from our DB and contain correct values. We end up with something like this:
[list type=decimal]
- Policy1 -> XY_Report_Reviewers: User1, User2
- Policy2 -> XY_Report_Reviewers: User3, User4
- Policy3 -> XY_Report_Reviewers: User1, User2
- Policy4 -> XY_Report_Reviewers: User3, User4
[/list]
Please be aware that our users can have access to multiple policies as stated in example above. So it is more or less N-M relationship.
Now in XY_Report class/document type, we have following:
XY_Report
- Policy -> single select lookup of type Policy
- Reviewers -> multi-select lookup of type Employee
On property Reviewers , we have used as a filter ("Filter the list by using the value of the following property") XY_Report_Reviewers from object type Policy to filter and get only those Employees who can review policy for specific XY_Report. Unfortunatelly, we end up getting all 4 users in Reviewers drop-down list: User1, User2, User3 and User4. This filter does not have any connection to currently selected Policy in metadata card. So in a nutshell, we have filtered Reviewers drop-down to those Employees who has access to review XY_Report but not to those users who has an access to review XY_Report and specific Policy.
What is tried out so far:
[list type=decimal]
- Trying to filter drop-down list of Reviewers implementing event handlers. We have tried implementing BeforeCreatenewObjectFinalize, AfterSetProperties but we were not able to find a way how to change the lookup behind Reviewers. We are always getting errors when trying to get a lookup with a call reviewers.GetValueAsLookup(). We have generally found out that API documentation describes VB development and not VBScript development so it is questionable if this is even possible in VBScripts.
- We have explored metadata card configuration as stated in many threads and have tried to use dynamic values & placeholders to filter values. We did not find a way to do it with these options either.
- We have created our own Reviewer object type with mult-select reference to Policy and have tried to use this object type as a sub-type of object type Policy. We have used it in another cases and get automatic filtering. But as stated above we have N-M relationship so this is not really possible because we have actually more owners.
[/list]
We would very thankful about your recommendations and suggestions. Are there any options in such cases when we need to filter additionally on runtime based on a value of some other property? What would be a best practice? We could also design it differently if there is a better way to solve this problem.
Best regards,
Dejan