Manage Learn to apply best practices and optimize your operations.

Hide parts of forms based on group membership

Are you tired of writing complicated Hide/When formulas? Try this instead.

View member feedback to this tip.

Have you ever want to hide a row of a table or one or more tabs of a tabbed table? Are you tired of writing complicated Hide/When formulas? Try this instead. Use one LotusScript subroutine to checkGroupMembership and set a field value. Base your Hide/When formulas on a much simpler statement -- i.e., "HideFieldFlags=0". Call checkGroupMembership from the PostOpen event. This subroutine checks if the current user is a member of a particular group, and if so, sets a field value to be used in Hide/When formulas.

Code: Sub checkGroupMembership

 Dim nabdb As NotesDatabase
 Dim groupdoc As Notesdocument
 Dim userName As New NotesName
 Dim view As NotesView
 Dim mems As Variant
 doc.HideFieldsFlag = 0
  doc.HideFieldsFlag = 1
  Call uiDoc.RefreshHideFormulas
  Exit Sub
 End If
 Set nabdb = New NotesDatabase
( db.Server, "names.nsf" )    
 Set view = nabdb.GetView( "Groups" )
 Set groupdoc = view.
GetDocumentByKey("Test Group 
Name", True )
 If groupdoc Is Nothing Then
  Messagebox "Error:  Cannot find the 
group document 'Test Group 
Name' in the Notes User Directory.  
Sub:  checkGroupMembership"
  Exit Sub
 End If
 Set mems = groupdoc.GetFirstItem
( "Members" )
 If mems.Contains( userName.canonical )
  doc.HideFieldsFlag = 1
 End If          
 Call uiDoc.RefreshHideFormulas
End Sub


I don't think much of this idea at all. A lookup to the address book every time you open a document using LotusScript? Hide/When formulas might be a bit of a pain to write, but they are fast and generally reliable.

Also, this won't work for a replicated application unless you use consistent ACL and have a full replica of the Domino Directory. All in all, this is one of the less well thought out tips I have seen.

—Andrew B.


I have to agree with Andrew, this is not the best solution -- especially on a busy server or where the user might be a member of a nested group. Look at the UserGroupNameList property first to get a list of group memberships.

—Brent H.


I agree with Andrew. I prefer using roles rather than group membership and base the Hide/When formula on them ( ! @IsNotMember or similar).

—Pierre B.


This is a really good tip in concept. Sometimes a form has design elements in different areas of the form that rely on the same Hide/When formula. That formula may be a bit complex, perhaps relying on data outside of Notes. This could help centralize the business logic -- so instead of changing the hide-when formula all over the place, you only need to change it once.

—Cutis W.


Why not just use @UserNamesList function?

—Gildas L.

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member Bill Gordon. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on LotusScript



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury