Manage Learn to apply best practices and optimize your operations.

Expand group members and nested groups in @formula

In R6, @expandgrouplist doesn't seem to work anymore. This @formula will get all members of groups, and it will also work for nested groups.

View member feedback to this tip.

In R6, @expandgrouplist doesn't seem to work anymore. This @formula will get all members of groups, and it will also work for nested groups.
 

ndb := @ServerName:"names.nsf";
vfield:[email protected](@DbLookup
("":"nocache";ndb;"($Users)";Group;"Members");
group);
REM {Store result here};
resultList:="";
REM {List of processed groups to avoid infinite loops};
 processGroups:=""; counter:=0; @While(@Trim(vfield)!= "";
 allv := @Trim(vfield);
 current := allv[1];
 
 type := @NameLookup([noupdate];current;"Type");
 @if( @LowerCase(type)="group";
  @Do(
   add:= @If( @IsMember(current;processGroups);
      "";
      @IfError(@DbLookup("":"nocache";ndb;"
($Users)";current;"Members");current));
   @If(@Trim(add)="";
    resultlist:=resultlist:add;
    add=current;
    resultlist:=resultlist:add;
    resultList:[email protected](resultList:add;current;"")
   );
   processGroups:[email protected](processGroups:current);
   vfield:[email protected](@Replace(allv;current;""):add)
  );
  @Do(
   resultList:=resultList:current;
   vfield:[email protected](@Replace(allv;current;""))
  )
  );  
 @StatusBar(@Text(counter)+" - "+ 
@text(@Elements(vfield))+") > " + vfield[1] + "...");
 counter:=counter+1
);
@Trim(@Unique(resultList))

MEMBER FEEDBACK TO THIS TIP

This solution is limited to R6 but it sure is simple.

 

REM {This formula expands a group name 3 levels deep.} 

resultList := group; 
@For(n := 1;n <= 3;n := n + 1; 
resultList := @Transform(resultList;"var";
@IfError(@DbLookup("";"85256648:005C15D7";
"Groups"; var; "Members");var))); 
@Trim(@Unique(resultList));

—Bruce F.

************************

A simpler solution that works fine in Notes 6 is:
@ExpandNameList(Server : Database; GroupName)
—J. Herman

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

Please let others know how useful it is via the rating scale at the end of the tip. 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 Lotus Notes Domino Formula Language

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com 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

SearchDataCenter
SearchContentManagement
Close