How to filter a Contacts property by User Groups

Hi, 

Similar to this from 4 years ago: https://community.m-files.com/forums-1552881334/f/m-files-clients/2927/filtering-by-property-values-user-belonging-to-a-specific-user-group

I have a User Group for 'Project Managers', which will be populated and syncd from Active Directory.

I have a Property called 'Project Manager', which is a 'Choose from list "Contacts" (multi-select)', and I want to filter that Property to only allow users who're in the Project Managers User Group

So on my Property, I select 'Show values from the following list:' as 'Contacts', and the the corresponding Filter, I filter by the Property of 'User Group (any property)' = Project Managers

Which should work right? but it returns 0 results when I try to use it on an object

So... Contacts objects are not aware of their User Group membership as being a Property they have

In fact Contact objects aren't held within User Groups at all, Contact objects can be linked to 'M-Files User' accounts, but it's those which are members of User Groups. 

So in the filter, I can filter by User Group (any property), or by 'M-Files User', but not by something indirect like 'M-Files User.User Group'

Any suggestions?

Many thanks

  • Looking further

    https://www.m-files.com/api/documentation/#MFilesAPI~VaultUserGroupOperations~GetGroupsOfUserOrGroup.html

    This API command seems useful, perhaps an Event Handler could run AfterModifyUserGroup to set a Property 'Is Project Manager' yes/no on my Contact objects when the User Group is updated, and then use that to Filter?

    Would Active Directory syncing trigger the Event though?

  • You can only filter by the properties that you can see on the Contact object's metadata card, so you would have to have the user group information in a property to be able to filter by it.

    There is a free module called User Synchronization that can automatically create and update Employee/Person objects with the user group information, you could check if that would help in your case. It can be configured to use an existing object type such as Contact if you want all your vault users to be created as Contact objects. User Sync module is delivered in the Compliance Kit vault application.

    If the User Sync module doesn't work in your case then the other option is to develop a custom extension like you suggested by monitoring when users are added to or removed from the Project Managers user group and updating the vault objects accordingly. In this case it could be something simple such as a Boolean "Is project manager" that is set to Yes for users in that user group like you mentioned. AD syncing should trigger the event as far as I know.