0
votes

I have a form (NewDocumentForm) where I create documents. And also there is a field (name: reader_field) that keeps roles of ACL that can read this document.

Next I create a view (MainView) to display this documents and I have a problem with View Selection formula.

My task is to show in MainView the documents to user where he has role to read this document (this role in reader_field).

So in Selection Formula I write the next:

SELECT (@Contains(reader_field; @UserRoles)); <- there is not that I need...

SELECT @IsMember(reader_field; @UserRoles); <- there is not that I need...

If you understand my question please give me advice. Thanks.

2
You can only see documents in view if you are member of the reader fieldpoisonedYouth
...or of an Authors-type field. Remember, being listed in an Authors field gives you explicit permission to edit the document (provided that you have at least Author access to the database), and you can't edit what you can't see. The field flag set is ``SUMMARY READ WRITE ACCESS` on an Authors field. It's surprising how few people seem to know that (or at least understand the implications), so if you weren't aware of it, you're not alone.Stan Rogers

2 Answers

3
votes

You can show all documents in view. You don't need to select the documents for user as the user can see only those documents in view the user has access to.

Actually, @UserRoles won't work in a view SELECT as the view is calculated on server. You could use private views but that has a lot of side effects you probably won't deal with. So, don't worry. Users will see only those documents in view they are allowed to by their roles.

1
votes

Is the field reader_field actually a Notes "Readers access" field ?

You can tell by checking the field in the Notes document properties box. You should see for that field:

Field Flags: SUMMARY READ-ACCESS NAMES

If that's the case, then the field reader_field will automatically limit who can see those documents in the view to those with the role in the field.

So your selection formula can allow everyone to view it, and the readers_field will limit it as necessary. This works for web applicaiton & Notes client.

Be sure to add a 'catch all' readers field as well as it's entirely possible to accidentally hide doecuments with a Readers field such that no-one can see them. If you add for example an [Admin] role (it can be in another field of type Readers on same doc) which only support staff have, then you have a way to see all documents, for support purposes.

If it's just a normal text field called reader_field....

If a Notes application: About your only option is to use private views (bit too much to explain here)

If a Web application: You can categorise the view by the reader_field and use a form to include the view with a view embedded element. Use the "Restrict To Category" setting to the user's role (if they have >1 role then you'll probably have to put some logic in to work out which one is appropriate)

Another alternative would be to display the view using an XPage, which allows you to trim the data as it's displayed.