Traitée Hide button based on group membership of user

  • venerdì 17 agosto 2012 10:55
     
     

    Hi,

    How to hide controls/buttons based on user group in Infopath 2010 list?

    How to get the group assigned to the logged-in user in InfoPath 2010 list.

    Thank you

Tutte le risposte

  • venerdì 17 agosto 2012 12:42
     
     

    Hi,

    You can write code for that. I have a code snippet. Hope you know how to write code in VSTO

     public void FormEvents_Loading(object sender, LoadingEventArgs e)
            {

              //calling function on form load event.

                this.GetGroupNames();
            }

     private void GetGroupNames()
    {
                  string strGroups = "";
                
      //store All group names of current user seperated by comma
       foreach (SPGroup group in SPContext.Current.Web.CurrentUser.Groups)           
           {

                  strGroups = strGroups + ", " + group.Name.ToString();
           }
               
             XPathNavigator field1 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field1",   NamespaceManager);
                field1.SetValue(strGroups);
     }

     
    • Modificato Raviraj9987 venerdì 17 agosto 2012 12:43
    •  
  • venerdì 17 agosto 2012 13:06
     
     Con risposta

    Hi,

    I am using sharepoint list in which vsta code is not possible.

    Also, i checked this:

    http://stevessharepointnuggets.blogspot.com/2012/05/infopath-2010-restricting-control.html

    This helped.

    Thank you

    • Contrassegnato come risposta Venkatzeus venerdì 17 agosto 2012 13:06
    •