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
(session.UserName)
 Dim view As NotesView
 
 Dim mems As Variant
 
 doc.HideFieldsFlag = 0
 
 If AccLevel = ACLLEVEL_DESIGNER 
Or AccLevel = ACLLEVEL_MANAGER Then
  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 )
 Then
  doc.HideFieldsFlag = 1
 End If          
 
 Call uiDoc.RefreshHideFormulas
 
End Sub

MEMBER FEEDBACK TO THIS TIP

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 SearchDomino.com 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.

This was last published in October 2004

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close