Check current user exist people or group column

How to check current logged in user name already exist in people or group column of share-point custom list 2013 using c#?
Note: People or group column contains multiple items.
Thanks in advance

You can use javascript to get current user and then perform vlookup on the field
Current use
function CallClientOM()
var context = new SP.ClientContext.get_current();
this.website = context.get_web();
this.currentUser = website.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args)
alert(currentUser.get_loginName());
function onQueryFailed(sender, args)
alert('request failed ' + args.get_message() + '\n'+ args.get_stackTrace());
http://spjsblog.com/2010/03/18/vlookup-type-rollup-for-sharepoint/
If this helped you resolve your issue, please mark it Answered

Similar Messages

  • People and group column become empty on EDIT ITEM

    Hi,
    I have 3 people and group columns(Peopleonly type) in my custom content type and list definition from the content type. When I EDIT an item from the list , the values in the 3 people and group column dissappear(meaning the fields are shown empty). Has
    anybody come across this behaviour. Any solution/workaround ?

    Hi Vipul,
    Did this only happen to the EditForm.aspx page of that custom list ? 
    Is this EditForm.aspx page customized ?
    Please also check whether there are some related errors in 14\LOGS.
    Please re-create another new EditForm.aspx page using the SharePoint Designer 2010, then check result again.
    Thanks
    Daniel Yang
    TechNet Community Support

  • Single line of text/email id to People or Group column

    I have a list of employee details, along with their SharePoint email ID. I want to import this list along with a new People or Group column, where it reads the email id and picks the correct user from Active Directory. How to import this?

    Hi Abul,
    Based on your description, I did a test. When I used users' email address in excel table and imported it to SharePoint list, the column would be saved as Hyperlink or Picture type. If I used Domain\User, after importing it to SharePoint list, the column
    would be saved as Single line of text type.
    It seems that it only is converted into Single line of text or Hyperlink type when you import a table into SharePoint list, by default. There is not a way to convert the table column in excel file into People column in SharePoint list.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Adding and removing current user from one SharePoint group to another with event receiver

    hi friends
    i need to change current user from one SharePoint group to another with list item adding event receiver.
    please help me

    Hi Malli,
    Greetings. Its nt possible
    http://sharepoint.stackexchange.com/questions/42286/event-receivers-on-add-remove-users
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Can't find "people or group"-column in database

    Hi,
    Where can I find the people and group column in the database in SharePoint
    2010? I need this for a report...
    I have a list with multiple columns. In the Table "AllUserData" I can find all information of the columns exept the people picker column.
    I found this solution:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/1e786892-1386-4e67-8a12-77f9ba0c1f64/where-can-i-find-the-people-or-group-columns-in-alluserdata-table-?forum=sharepointdevelopmentlegacy
    But there they are talking about "tp_LeafName" and "tp_DirName" and I can't find these columns...
    Any idea?

    Found it, needed this tables:
    [AllDocs]
    [AllUserData]
    [AllUserDataJunctions]
    [UserInfo]

  • Unable to select SOME external users in person or group column in SharePoint O365

    Here's a head scratcher.
    We have an O365 SharePoint(G3) instance.
    Sent external users invites to join the site from the SharePoint Group that the external user will be placed.
    External users accepted invitations and now have access to the site with the correct permissions.
    Permissions assigned to SharePoint Group.
    Some external users can be selected for "Assigned to" field (person or group column type).
    Some external users canNOT be selected for "Assigned to" field (person or group column type).
    When typing external users name that canNOT be selected, the error message "No results found" appears.
    Went to Site Settings > Site Permisisons > Check Permissions and typed in external users name that canNOT be selected, the error message "No results found" appears.
    I have no idea why this would happen for some external users and not others.
    External users that can be selected and those that canNOT be selected are in the same SharePoint Group and have the same permissions.
    Could this be due to how the external user set up their account?
    Help me please. This is driving my crazy.
    Thanks in advance.
    Tamara
    The Stumped SharePointer
    Tamara Bredemus SharePoint Minion...working up to Maven

    Hi Miikka,
    can you try cleaning up the user information list via powershell and reconfigure the userprofile sync.  following url contains the powershell script for user information clean up
    http://blog.fpweb.net/how-to-clean-up-sharepoint-user-information-list-with-powershell/#.VPrbn_mUeSo
    Regards  Roy Joyson
    Please remember to mark your question as "answered"/"Vote helpful" if this solves/helps your problem.
    Roy Joyson

  • Getting current user's  member of group

    Hi expert(s),
    I have developed web application using jsp, now i need to know whether the current user logged in at client PC, is member of certain group available in the database, i can get current user using System.getProperty(), but i have to get the list of groups, he/she belongs to. So that i can check his group to authenticate...
    What is the workaround?
    Waiting for your kind reply.
    Thanks & Regards,
    Sri.

    Experts, i give you .net code for done my need, i need to convert/use it in java platform, please give me some useful tips.
    If G_sSecurityMode = "ADSL" Then
                    GUser = System.Environment.UserName
                    ReDim sGroup(6)
                    'Default NT user groups which will be created at every system during installation
                    sGroup(0) = "CPMSDOMAINADMIN"
                    sGroup(1) = "CPMSCLIENTADMIN"
                    sGroup(2) = "CPMSDATAPREPADMIN"
                    sGroup(3) = "CPMSDATAPREPUSER"
                    sGroup(4) = "CPMSINVENTORYADMIN"
                    sGroup(5) = "CPMSINVENTORYUSER"
                    G_sUserGroup = " "  'Global variable defined in GLbdecleration module
                    'Loop defined to identify  the group(s) associated with the current NT user
                    For i = 0 To 5
                        objGroup = GetObject("WinNT://" & sMachine _
                         & "/" & sGroup(i) & ",group")
                        For Each objUser In objGroup.Members
                            If UCase(GUser) = UCase(objUser.Name) Then
                                G_sUserGroup += "'" + sGroup(i) + "'" + ","
                            End If
                        Next
                    Next
                    G_sUserGroup = G_sUserGroup.TrimEnd(",") 'To truncate the last "," in a g_susergroup string
                    If Len(Trim(G_sUserGroup)) = 0 Then
                        MsgBox("No group(s) defined for the user " + GUser, MsgBoxStyle.Information)
                        Me.Close()
                    End If
                Else
                    MsgBox("Invalid Security Definition", MsgBoxStyle.Information)
                    Me.Close()
                End If

  • How can I add new user in sharepoint list column (people or group) or in sharepoint group using loginName only

    Hi
    If I have only login name of any user like - "Donamin\login_name".
    If this user is not present in sharepoint portal.
    How can I add this user to people or group column of any list or in any  sharepoint group with permission?

    hi
    got the issue
    it should be  like this -
    string userloginname = @"DOMAIN001\vyankatesh_mujumdar"
    using (SPSite oSpSite = new SPSite(site.ID))
    using (SPWeb web = site.OpenWeb())
    try
    { SPList lst = web.Lists["TestList"];
    string userloginname = @"DOMAIN001\vyankatesh_mujumdar";
    web.EnsureUser(userloginname);
    SPUser oSPUser = web.SiteUsers[userloginname];
    SPFieldUserValue FieldValueName = new SPFieldUserValue(web, oSPUser.ID, oSPUser.LoginName);
    SPListItem oSPListItem = lst.Items.Add();
    oSPListItem["Title"] = userloginname;
    oSPListItem["People"] = FieldValueName;
    oSPListItem.Update();
    catch (Exception ex)
    ExceptionManager.LogErrorInFile("--------Exception -------", bIsLogEnabled);
    ExceptionManager.LogErrorInFile(ex.Message, bIsLogEnabled);
    ExceptionManager.LogErrorInFile(ex.Source, bIsLogEnabled);
    ExceptionManager.LogErrorInFile(ex.StackTrace, bIsLogEnabled);
    ExceptionManager.LogErrorInFile("-------------------------------------------------------", bIsLogEnabled);
    Thanks for all for the reply

  • Restrict group to edit users in people picke in infopath

    hi
    I have a document with people picker I want to restrict group A to pick or edit the users in existing document and groupB able to edit the users in people picker how is it possible to make it in InfoPath.

    Hello,
    This would be easy to do with groups that can access specific sections of the form and then use SharePoint or AD groups to govern access, but unfortunately it does not work in InfoPath. 
    One alternative possibility is to set up a list in SharePoint and enter the names of the smaller group of people into that list (Person field).
    The InfoPath form has a data connection to that list. The form has one section with a people picker and another section with a calculated field that shows the value of the people picker. 
    When opening the InfoPath form, check if the current user exists in the list and hide the section they should not see.
    cheers, teylyn

  • Caml query to check current logged in user - SharePoint designer

    Hi,
    I need to create a caml query in SharePoint designer to satisfy the below conditions.
    If the logged in user (current user) is a member of a specific group. e.g. Group Name = ISS Owners, ID=5
    (OR)
    If the logged in user (current user) exists in assigned to field. e.g. Field Name = Assigned To
    Reference to the below link is not working for my solutions.
    Membership Element (Query)
    CAML Query – Membership attribute
    Kindly help in resolving caml query issue.
    Anandhan.S Remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

    The second condition is pretty straightforward
    <Eq>
    <FieldRef Name="AssignedTo"/>
    <Value Type="Integer">
    <UserID />
    </Value>
    </Eq>
    but I don't think you can do the former. The <Membership> condition can only be applied to a <FieldRef>, not a generic <Value> argument.
    But what would be the purpose of the first condition in the first place? It's invariant, not related to specific list items. Or is the requirement to return all items if the user is a member of a group (Administrators?), but only assigned-To items if not:
    If so, is there some way you can refactor the check for the former condition into some higher level logic? 

  • Send an Email to those who are marked in people/group column

    In the discussion boards, I would like to add a people or group column.
    So whenever some name is mentioned in that column, I would like an Email to be triggered to that particular person or group.
    If this is been created through Task list,  I know it would be possible. But I want to achieve the logic of discussion board and want to trigger an Email to someone who might be interested in that particular discussion.
    Is there a way to do it ?
    Came across this forum which exactly talks about my requirement.
    https://social.msdn.microsoft.com/Forums/sharepoint/en-US/1e2f233d-2077-422a-bbd0-098c065b90ce/how-to-send-email-to-people-and-group-field?forum=sharepointadminprevious
    But is there any easier and alternate way to do this? Thanks in advance.
    Veeramani.S

    Hello Veera. S,
    You can look this tutorial for SPD 2013: http://msdn.microsoft.com/en-us/library/office/jj554671(v=office.15).aspx
    Or this for SPD 2010: http://sharepoint-videos.com/module-1/sp10creating-a-workflow-on-a-list-using-sharepoint-designer-2010/
    http://blogs.msdn.com/b/edhild/archive/2011/06/01/creating-custom-workflow-task-approval-forms-with-sharepoint-designer-2010.aspx
    http://office.microsoft.com/en-001/sharepoint-designer-help/introduction-to-designing-and-customizing-workflows-HA101859249.aspx
    If a post answers your question, please click Mark As Answer on that post and
    Vote as Helpful

  • How to add users from person or group field in a sharepoint list to sharepoint group

    Hi,
    How to add users(single or multiple) from person or group field in a sharepoint list to sharepoint group programmatically?
    Any suggestions would be appreciated.
    Thank you,
    AA.

    Hello,
    Use SPGroup.AddUser() method to add user in group. I have just written sample code in notepad so it is not tested:
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using(SPSite Site = new SPSite(SPContext.Current.Site.Url))
    Using(SPWeb Web = Site.OpenWeb())
    SPList list = web.Lists["ListName"];
    SPQuery query=new SPQuery ();
    query.Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Test</Value></Eq></Where>";
    SPListItemCollection items = list.GetItems(query);
    if(items.Count > 0)
    foreach(SPListItem item in items)
    //Get USers from person or group column
    SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users");
    SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString());
    SPGroup spGroup = spSite.RootWeb.Groups[groupName];//group name
    if (users.Count != 0)
    bool isUserInGroup = false;
    foreach (SPFieldUserValue user in users)
    foreach (SPUser item in spGroup.Users)
    string itemUserName = item.LoginName;
    string UserName = user.User.LoginName;
    if (itemUserName == UserName)
    isUserInGroup = true;
    break;
    if (!isUserInGroup)
    spGroup.AddUser(user.User);
    The above code will query list item and then get users from "Users" column. Now it will check whetehr user is already in group not, if not then add user in group.
    http://rajanijilla.blogspot.sg/2012/09/add-users-to-group-programmatically.html
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Filter base on Person or Group column does not work correctly in sharepoint 2013

    I have a list that contain "Person or Group"column that set "Allow Multiple Selections" to yes.
    In sharepoint 2010 I create view and filter it base on this person or group column equal to [Me]. And it's work correctly.
    Now in sharepoint 2013 when I filter view, base on this person or group column equal to [Me], it does not show me any items, although list has data that person or group column set to me.
    What's wrong?
    Thanks.

    If you want to filter the list view when current user is in the group, then I recommend to use theMembership comparator in the
    query and add it to the view page in SharePoint Designer:
    <Where><Or><Membership Type="CurrentUserGroups"><FieldRef Name="AssignedTo"/></Membership><Eq><FieldRef Name="AssignedTo"/><Value Type="Integer"><UserID Type="Integer"/></Value></Eq></Or></Where>
    More reference:
    http://decodesharepoint.blogspot.com/2010/01/filter-list-views-by-user-groups.html

  • Active Directory Script-Find if users exist

    Import-CSV "L:.\Users.txt" -header ("UserName") | % {
       $UserN = $_.UserName
       $ObjFilter = "(&(objectCategory=person)(objectCategory=User)(samaccountname=$UserN))"
       $User = Get-ADUser -Filter {sAMAccountName -eq $UserN}
     $objSearch = New-Object System.DirectoryServices.DirectorySearcher
     $objSearch.Filter = $ObjFilter 
     $objSearch.SearchRoot = "LDAP://ou=Remove this if you dont want only users in a OU returned,dc=Domain,dc=co,dc=uk"
     $AllObj = $objSearch.findOne()
     $user = [ADSI] $AllObj.path
     $ErrorActionPreference = "silentlycontinue"
     If ($User -eq $Null) {Write-host "Domain\$UserN does not exist in AD"}
     Else {Write-host "Domain\$UserN found in AD"}
    -Can anybody help me step by step. I just started using powershell today. I am trying to use powershell to check if users exist in AD. I manage to create a script to check for one user at a time but, I really what a script to check multiple users at
    the same time. This script is currently telling me everybody does not exist. Even if I put a user that does.

    Thanks for the quick help & advice.
    here are some example of names in the text file.
    Flewellen,  Joel A
    Golla  Wipperfurth,Linda
    Grestner,   Allen
    - I want to make sure the names in the text file do not exist in AD(Display name). Can I use your script for this? Again, I am a total noob.Currently reading about powershell.
     example does notwork:
    Import-Module ActiveDirectory
    Import-CSV "L:.\Users.txt" -header ("DisplayName") |
    Foreach {
            if (Get-ADUser -Identity $_.DisplayName -ErrorAction SilentlyContinue) {Write-host "Domain\
    $($_.DisplayName) found in AD"}       
            else {Write-host "Domain\$($_.DisplayName) does not exist in AD"}
    I think i have to change the Get-ADUser -Identity $_.UserName

  • Checks users Exists in user group or not?

    Hi All,
    bool userExsists = SPContext.Current.Web.CurrentUser.Groups.Cast<SPGroup>().Any(g => g.Name.ToLower() == "groupname".ToLower());
    Is there ay alternative for findings that user is in group or not? Is it best way to achieve this?

    Hi,
    To check if a user exists in user group, please use the code below:
    string userName = "contoso\\admin";//your user account
    string groupName = "SP Members";// your user group
    using (SPSite spSite = new SPSite("http://sp")) // your site collection URL
    using (SPWeb spWeb = spSite.OpenWeb())
    SPUser user = spWeb.EnsureUser(userName);
    if (user.Groups.Cast<SPGroup>().Any(g => g.Name.Equals(groupName)))
    Console.WriteLine("User " + userName + " is a member of group " + groupName);
    else
    Console.WriteLine("User " + userName + " is NOT a member of group " + groupName);
    Or you can use PowerShell command below:
    $w = get-spweb http://my
    $gs = $w.SiteGroups
    $g = $gs[12]
    $user = $g.Users.GetByEmail("[email protected]")
    if($user -eq $null){write-host "User Not Found"}
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

Maybe you are looking for

  • Using # & p in saved contact numbers

    I use a company voicemail and used to be able to add extra pauses and characters to a saved number in order to access the system. This no longer works since I have IOS5. Any suggestions?

  • Broadband regularly dropping out

    I am losing the will to live !!! BT technical support in India is apalling (and please do not misinterpret this, I have nothing against India or Indian people). They seem to work to a set script, which is repeated at every level of support, and if yo

  • Pricing Condition - User Status

    Currently we use SD for Service Billing (No physical materials). My question is around using "User Status" to drive Pricing Procedures. Can we do this? Is it advisable? I work for an Electric Utility, so we have a wide-range of billing, all around di

  • Can't connect to a some sites

    since a couple of days I can not reach some sites. examples are: http://www.brushesapp.com/ http://tweepsapp.com/ all internet connections are just fine, there are just a very few sites i can't reach. but i can reach them with gprs on my iphone so i

  • Razer Abyssus mouse sends click events but no movement in X

    This is very strange: my mouse sends click events to X, but it does not move the cursor.  I don't have any funny packages installed and don't have an xorg.conf.  What can I do to make my mouse work? Bus 005 Device 003: ID 1532:001c Razer USA, Ltd RZ0