locked
how to make control as readonly control for visitors group users RRS feed

  • Question

  • Hi All,

    I have created a form  and it is working fine. Presently the users who logged in from Visitors group they are able to see the form and also able to modifiy it. Now my client requirement is, when the users logged in and is from Visitors Group, then all the controls should be in readonly form.

    OR

    How to get the logged in user group name.

    Can some one please help me on the above requirement.


    Mohammed


    • Edited by MercuryMan Monday, March 26, 2012 7:55 AM
    Monday, March 26, 2012 6:22 AM

All replies

  • Hi,

    Coulmn level permission is not provided by sharepoint by default so you have to write some code to implement this or else you can use some java script (no idea of script but you can find with some googling).

    below is the sample code:

    using (SPSite mySite = new SPSite("siteURL"))
    {
    using (SPWeb myWeb = mySite.OpenWeb())
    {
    SPList myList = myWeb.Lists["ListName"];
    SPField myField = myList.Fields["ColName"];
    myField.ReadOnlyField = true;
    myField.Update();
    }
    }

    If you are using MOSS 2007 then you can also try with below tool.

    http://splistdisplaysetting.codeplex.com/

    Hope it could help


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Monday, March 26, 2012 9:36 AM
    Moderator
  • Hi Hemendra,

    Just to update you, my above requirement is for Infopath Form 2007. I wanted to know, if the logged-in user is belongs to which group. If the user is form Visitors Group then all the controls state should be read-only mode.

    Can this be possible with out writing code?


    Mohammed

    Monday, March 26, 2012 12:49 PM
  • Hi,

    I have used the below article for same type of requirement many times. You can also follow the same:

    http://jaliyaudagedara.blogspot.in/2011/05/getting-current-users-sharepoint-group.html

    make sure that this process will work with only windows / classic authentication.  It does not work with FBA auth.

    Hope it could help


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Monday, March 26, 2012 12:56 PM
    Moderator
  • Hi,

    When i was trying to configure the "GetGroupCollectionFromUser" web service, its giving me the below. Can you please help me on this.


    Mohammed

    Tuesday, March 27, 2012 6:49 AM
  • Hi,

    *Check login name in your site collection. It must be there.

    *Specified user must be added in some user group.

    * Where are you getting this error? Can you please tell us in detail.


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Tuesday, March 27, 2012 9:08 AM
    Moderator
  • Hi,

    Thanks for the above points now i have successfully crated the "GetGroupCollectionFromUser". now i have a form in my local drive c.

    • To change the GetGroupCollectionFromUser1.xsd i have renamed my form form Template.xsn to Template.cab
    • Extracted the GetGroupCollectionFromUser1.xsd to new folder
    • Opened in a notepad
    • modified the file as per the instructions from the blog is done successfully

    Now my problem is i am unable to place the GetGroupCollectionFromUser1.xsd back to "Template.cab" file. 

    • Is there any other way to do changes in GetGroupCollectionFromUser1.xsd file with out changing its extension form .xsn to .cab extension?
    • any other procedure?

    Note: when i can able to open manifest.xsf file in designe mode.


    Mohammed


    • Edited by MercuryMan Tuesday, March 27, 2012 1:23 PM
    Tuesday, March 27, 2012 12:26 PM
  • Hi,

    I have opened manifest.xsf file in designe mode and saved the file with new name "Extracted.xsn". Now i am able to open the form.

    I have a requirement to display logged-in user detais with group name. As per the blog which you have given i have configured

    • Configured the textbox for logged-in user AccountName (GetUserProfileByName : Secondary dataconnection)
    • Configured the textbox for logged-in user PreferredName (GetUserProfileByName : Secondary dataconnection)

    Unable to get the logged-in user group name in the third text box. can you please help me on this in setting up the rules/conditions for the text box to get group name. please see the below image


    Mohammed


    • Edited by MercuryMan Wednesday, March 28, 2012 6:39 AM
    Wednesday, March 28, 2012 6:37 AM
  • Hi,

    Just follow the Step 06 (as  mentioned in article) to get current user group name.

    1. Create action rule on form load

    2. Set velue of your text box as GetGroupCollectionFromUser ---> Name

    It may not work for system account so first publish the form and check.

    Let us know if it works


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Wednesday, March 28, 2012 6:47 AM
    Moderator
  • Hi,

    I have created a rule on form load as shown below

    I have a two users added in two different groups (1. Ahmed in Templates Owner group and 2. Mohammed in Templates Member group).

    when i logged in with Ahmed it is displaying group name as Template Owner.

    when i logged in with Mohammed then also it is displaying group name as Template Owner insted of Templete Member

    can you please help me on this to get correct logged in user group name.


    Mohammed

    Wednesday, March 28, 2012 7:38 AM
  • Did you check Mohammed name in Templates Owner group?

     Iin your case, condition window is not required to get group name. Just set the value as @name and ok.


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Wednesday, March 28, 2012 7:58 AM
    Moderator
  • I have checked "Mohammed" is not available in Templates Owner group.

    as per your suggestion i have removed the condition and just placed value as @name. when i logged-in with mohammed again it is showing Templates Owners group name insted Templates Members

    Is there any thing else i have to do like setting condition/rules etc?


    Mohammed

    Wednesday, March 28, 2012 8:51 AM