Switch view based on user login Sharepoint group - InfoPath Dev
in

InfoPath Dev

Switch view based on user login Sharepoint group

Last post 07-24-2013 06:13 AM by kwasidenkyira. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 04-30-2012 07:47 PM

    Switch view based on user login Sharepoint group

    I have created two views of  Infopath 2010 browser enabled forms.I have also created a sharePoint 2010 groups called "approvers".  I need to switch views based on the user's in the approvers group. Any help please. I will like VSTA code based solution but a non-code based with clear explanation will help.

  • 04-30-2012 10:12 PM In reply to

    Re: Switch view based on user login Sharepoint group

    Hello,

    You can probably add a rule on Form Load that switches views based on condition (CurrentUser = approver1), something like that.

    Jo-Anne

    Jo-Anne Alfafara
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™
  • 05-01-2012 09:58 AM In reply to

    Re: Switch view based on user login Sharepoint group

    Hi

    I have solved the issue with nine simple lines of code. I looked at most of the solutions on the web and none including the one from clayton is addressing how to switch Infopath 2010 browser enabled forms views based on a login user's sharePoint groups in a simple way , so I have decided to share my code so others facing the same challenges can follow:

    1. Create a group in your SharePoint site, in this example I called my "Administrators"

    2.Behind the Infopath 2010 form-->Developer--->Loading Event

    3.Add references to a): using Microsoft.SharePoint and b) using Microsoft.SharePoint.Security

    4. Add the code below to the public void FormEvents_Loading Event and give full trust to your Infopath 2010 form. Enjoy it !!!. It works like charm SPSecurity.RunWithElevatedPrivileges(delegate(){
    using (SPSite mySite = new SPSite("http://yourser/SitePages/default.aspx"))
    {
    using (SPWeb oWeb1 = mySite.OpenWeb())
    {
    if (oWeb1.IsCurrentUserMemberOfGroup(oWeb1.Groups["Administrators"].ID) == true)
    {e.SetDefaultView(
    "ReviewersView");
    }
    else
    {
    e.SetDefaultView(
    "View 1");
    }
    oWeb1.Close();
    mySite.Close();
    }
    }
    });
    }

  • 07-24-2013 02:12 AM In reply to

    Re: Switch view based on user login Sharepoint group

     Hi,

     I am trying to implement the same code on my form which is a web enabled browser for 2010 and I cannot publish this as the programming language is incompatible to web enabled forms. Can you please let me know how you successfully implemented it.?

    Dhiran

  • 07-24-2013 06:13 AM In reply to

    Re: Switch view based on user login Sharepoint group

    Go behind the Infopath form and change the programming language to C# Click on “File”, then “Options”, then click on “More Options” under the title “InfoPath Options” and then click on the “Design” tab in the new window that opens up. The default programming language is listed in the “Programing Defaults” section of the new window. You can even select the location where your code will be stored. Change the defaults to your liking and click on OK. Sorry I have to change login. I have lost my password, resetting password but having trouble doing that. So I have to create a new login Id to help
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.