How to Insert Sharepoint 2013 Person or Group Field using VBA

Hello,
How to Insert Sharepoint 2013 Person or Group Field using VBA , I tried set the field with ID / ID;Name / Name
but all failed, Please advice 
Function SetSP_Field(F_Yer As Single, F_WekNo As Single, F_ProjectNum As String, strField As Variant, strFieldValue As Variant) As String
' test code
    Dim rst         As Recordset
    Dim strSQL      As String
    Dim SP_RecSet   As ADODB.Recordset
    Set SP_RecSet = New ADODB.Recordset
    SetSP_Field = False
    strSQL = "Status Report"
    On Error Resume Next
    Call SP_Connect(2)
    strSQL = "select " & SP_List & ".* From  " & SP_List _
           & " Where [Year] = " & CInt(F_Yer) _
           & "   and [WeekNo] = " & CInt(F_WekNo) _
           & "   and [Compass_Code] = '" & F_ProjectNum & "' ; " _
'           & " Set " & strField & " = " & strFieldValue
    'Debug.Print strSQL
    'Debug.Print SP_CN
    SP_RecSet.Open strSQL, SP_CN, adOpenStatic, adLockOptimistic
    If SP_RecSet.RecordCount = 0 Then
        Debug.Print "Record for project: " & F_ProjectNum & " not found"
        LogFile.WriteLine ("Record " & strID & " not found")
    End If
    If Not SP_RecSet.EOF Then
        'SP_RecSet.Edit
        SP_RecSet.Fields(strField) = strFieldValue
        SP_RecSet.Update
        If Err.Number <> 0 Then
            MsgBox ("SP Update Error: " & Err.Description)
            GoTo Exit_Fun
        End If
        SetSP_Field = True
    End If
Exit_Fun:
    SP_RecSet.Close
    Set SP_RecSet = Nothing
End Function

Hi Tim,
Let’s verify the followings:
Whether this issue occurred for other lists in the same site.
Whether this issue occurred for all users who don’t have full control.
Whether this issue occurred on other sites.
When you created the people & group column, which show field did you used? Please try to use a different show field for the people & group column, compare the result.
In addition, please check if the link is useful:
http://www.learningsharepoint.com/2013/08/21/empty-value-in-people-picker-after-saving-the-list-form-in-sharepoint/
Best Regards,
Wendy
Wendy Li
TechNet Community Support

Similar Messages

  • 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

  • How do I populate a "Person or group" field via Elements.xml?

    So I have created a field titled "EmployeeName" and it's a "Person and Group" type. (View the Schema.xml below)
    <Field Name="EmployeeName" ID="{8579a35a-71a8-4070-b907-b6ede0daa352}" DisplayName="Employee Name" Type="User" />
    Now, I'm trying to populate the column via the Elements.xml file. As you can see by the commented out code below, I've tried every combination and I'm still unable to populate this column:
    <ListInstance Title="Employee_Rec_list" OnQuickLaunch="TRUE" TemplateType="10000" Url="Lists/Employee_Rec_list" Description="My List Instance">
    <Data>
    <Rows>
    <Row>
    <!-- <Field Name="EmployeeName">i:0#.f|membership|[email protected]</Field>
    <Field Name="EmployeeName">i:0#.f|membership|[email protected]</Field>
    <Field Name="EmployeeName">0#.f|membership|[email protected]</Field>
    <Field Name="EmployeeName">#.f|membership|[email protected]</Field>
    <Field Name="EmployeeName">[email protected]</Field> -->
    <Field Name="EmployeeName">[email protected]</Field>
    <Field Name="Achievements">Rock Star</Field>
    <Field Name="Achieve_x005f_Des">Cras congue varius metus, in tincidunt metus Vestibulum vel turpis nec leo porttitor pulvinar fringilla ut lacus. a dictum aliquam. Pellentesque non felis cursus, lobortis, mattis arcu. Duis molestie nisi quis lectus tincidunt, a porttitor turpis iaculis. Donec condimentum, tellus sit amet hendrerit aliquet, est eros faucibus nulla, eu ultricies ligula ante id quam. Suspendisse suscipit orci sit amet vestibulum ultrices. Nunc dictum tortor non magna volutpat</Field>
    </Row>
    </Rows>
    </Data>
    </ListInstance>

    Ok I figured it out. You need to you use the users ID.
    <Field Name="EmployeeName">15</Field>

  • Copy person & group field value to another person or group field programmatically

    Hi 
    I have one user list in SharePoint sitecollection1 having User in Title(having simple user name) and UserName in Person or Group type field.
    I want to copy this list into my site list with same column names programatically using timer job.
    How I can copy the person or Group field from siteColletion1 to person or group field of sitecollection2(my site),
    as both column types are same.
    Pleas suggest any solution.

    I am getting user name and user id using following code,
    foreach (Microsoft.SharePoint.Client.FieldUserValue userValue in oclistItem["UserName"] as Microsoft.SharePoint.Client.FieldUserValue[])
    string username =    userValue.lookupValue.tostring();                               
    But how to get the login name ? or how can I get the User Object from this field?
    Anybody got this type of issue before.
    Please suggest any solution

  • Sorting and filtering by select-multi person or group field in the list in SharePoint 2013

    Hi everybody,
    In SharePoint 2013, I have defined a column as "Person or Group" field, which you allow for multiple selections. when I try to sort/filter it by this field in the list. The field doesn't show up in the dropdown. If I changed "Allow multiple
    selections" option to "No" by clicking the column name to edit it in "List Settings", the field can show up sort in the dropdown.
    How about support sorting and filter by select-multiple "Person or Group" field in sharepoint 2013?
    BTW, in SharePoint 2010, it can support this issue no matter what the "Allow multiple selections" option the request is.
    Any help would be great!
    Thanks,
    Jodie

    Hi Jodie,
    Can you please give this as a try.
    To fix the Filter Issue on Assigned To Column. We need to run the following scripts.
    The field which allows more than one values or which allows multiple selections. The multi-valued fileds are non-sortable,
    non-filterable. Multi-valued fields cannot be indexed
    $web=Get-SPWeb
    $list=$web.Lists[] $field=$list.Fields[ColumnName] $strSchema=$field.SchemaXml $str=Schema$strSchema.Replace("Sortable=`"FALSE`"","Sortable=`"true`"")
    $field.SchemaXml = $strSchema
    Krishana Kumar http://www.mosstechnet-kk.com
    Thanks for your reply, I have tried to run the scripts, but it still cannot work. The following is my scripts:
    $web=Get-SPWeb 'http://cst-server-01'
    $list=$.web.Lists["Product Request"]
    $field=$list.Fields["Applicant"]
    $strSchema=$field.SchemaXml
    $str=Schema$strSchema.Replace("Sortable='"FALSE'"", "Sortable='"True'"")
    $field.SchemaXml = $strSchema

  • How to add SharePoint 2013 Promoted link list view web part in page programatically with Tiles view using CSOM.

    How to add SharePoint 2013 Promoted link list view web part in page programatically with Tiles view using CSOM. I found that it can be
    done by using XsltListViewWebPart class but how can I use this one by using shraepoint client api.
    shiv

    Nice, can you point me to the solution please ?
    I'm  trying to do this but I get an error : 
    Web Part Error: Cannot complete this action. Please try again. Correlation ID: blablabla
    StackTrace:    at Microsoft.SharePoint.SPViewCollection.EnsureViewSchema(Boolean fullBlownSchema, Boolean bNeedInitallViews)     at Microsoft.SharePoint.SPList.GetView(Guid viewGuid)   
    All help really appreciated.

  • How to modify person or group field value with new value

    Hi
    I have person or group field having property Person Only.
    Thsi firls already have one value. Now I want to update it but this code to update value is not working.
    string myName = @"ABC\myname";
    web.EnsureUser(myName);
    SPUser myUser = web.SiteUsers[myName];
    SPFieldUserValue myNamevlaue = new SPFieldUserValue(web, myUser.ID, myUser.LoginName);
    oSplistItem["My_x0020_User"] = myNamevalue;
    oSplistItem.Update();
    I am getting myNamevalue correct in the veriable. But why its not updating in the list?
    is there any issue in the above code?
    Do I need to delete previous value and then update new value in this field? How?

    Hi,
    The format of the user value in people/Group field must be
    ID;#Name, you can use the following code snippets to update the people/group field.
    string loginName = "ABC\\myname";
    SPUser user = web.SiteUsers[loginName];
    SPList list = web.Lists.TryGetList("ListName");
    if (list == null)
    Console.WriteLine("list is not exist!");
    return;
    SPListItem item = list.GetItemById(3);
    item["My_x0020_User"] = user.ID.ToString() + ";#" + user.Name;
    item.Update();
    Thanks,
    Jason
    Please remember to mark the reply as answer if it help, and unmark the answer if it provide no help.

  • How to Enforce Sharepoint 2013 content type validation rules when modifying document using Word 2013

    Good day,
    I have two date columns (Start Date and End Date) in a content type in Sharepoint 2013.  A file library uses this content type.
    In the document template I have the two dates (Start Date and End Date) showing in the Document Panel.  I can edit them well enough and they show in the document correctly.
    In the content type I have validation rules that the End Date must be greater than the Start Date. 
    The question is, how can I enforce this validation on the client side in Word.  Is there anyway to achieve this?
    The user will not have access to change the document properties in Sharepoint. (Not my call)
    Thank-you!

    The "panel" is called the Document Information Panel in SharePoint. You can customize this using InfoPath from the page where you created / edited your Content Type. Go to Settings, Site Settings Content Types, edit your content type, click Document
    Information Panel and then click "Edit this template". In InfoPath you can create a Rule to enforce your dates.
    This may require the Enterprise Edition of SharePoint to support the InfoPath Forms Services.
    Mike Smith TechTrainingNotes.blogspot.com
    Books:
    SharePoint 2007 2010 Customization for the Site Owner,
    SharePoint 2010 Security for the Site Owner

  • Save history values of person or group field in another person or group field

    Hi
    I have a person or group field in sharepoint list that users can assign task to colleagues by this column. Every time value of this field changed and I want to save
    these values in another person or group field (for history and 
    filter view base on it).
    How I can do this?
    Thanks.

    I create workflow variable and give it these values:
    First Person/Group value,(Display Names, Semicolon Delimited),
    Second Person/Group value,(Display Names, Semicolon Delimited)
    Then I set this variable to Second Person/Group but it's give me error and does not work.

  • SharePoint 2013 Active Directory Groups represented as c:0+.w| SID in UserInformation list instead of c:0+.w|Domain\Groupname

    Hi
    We are running on SharePoint Server 2013.When we add AD groups as permissions, we see that the group name is being displayed properly in the permissions. Whereas when I click on the groupname I see the SID with the Sharepoint specific claims characters,
    instead of domain\groupname. I understand that the claims characters are because of claims mode. But I expected domain\groupname instead of SID. Is this the right behaviour.
    When I call SiteData.GetContent web service, I get the SID of the group name instead of the domain\groupname.
    Can someone please clarify?
    Thanks
    Naga

    Hi,
    Yes, the identity claim for an AD group is based on the SID of the group. The claim encoding for an Active Directory group consists of the following sections:
    c:0+.w|<SID>
    •"c" for a claim other than identity
    •"+" for a group SID
    •"." for a string
    •"w" for a Windows claim
    More information:
    http://www.sharepointfire.com/MyBlog/2013/11/get-ad-group-identity-claim-in-sharepoint-2013/
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Need to know how to allow mail to be sent to my Hosted Sharepoint 2013 site's documents folder/ Using CRD 7 reporting

    I have gotten as far as adding a new app, naming the folder and going into CRD, for the report we need online and attempted to enter the settings information for our sharepoint site. The issue is no matter how I enter the credentials it will not authorize
    and finish the connection. We have tried a couple of different things when it comes to the user name and domain line. we tried: 
    corporate\username; 
    corporate-traffic.com\username; 
    [email protected]..
     we are trying to figure out the correct way to enter this information, mainly what the domain name should be since Sharepoint 2013 is all cloud based.
    My issue is when I get to entering credentials none of my admins credentials work... I think it may be the domain name that is throwing it off. I keep getting the error: server was unable to process request ---> Access is denied. (Exception
    From HRESULT: 0x80070005 ((E_ACCESSDENIED))
    So can anyone point me in the right direction to fix this error and enable the report to email to my sharepoint site documents folder? 
    Just to clarify...
    I need the correct domain info per office 365's Sharepoint to enter the info into our report options on CRD seven report. And how we can enable SMTP to our documents folder on our SharePoint site.

    I asked Christian Steven's Support staff about this and they came out with a fix to allow us to do exactly what I asked in the first post.
    We then had an issue with an error saying Crystal Reports couldn't find the rasauditingw.dll. After a few months of going back and forth they finally looked deeper into the issue and informed me other businesses are having the same issue with the add in
    they designed. They still claim it is not there software but Crystal Reports software that is the issue.
    Just to clarify, the error only appeared after the add in was put in place. Anyways, after they dug some more the following post was the end game.
    "The development team was finally able to get into this issue (seems other businesses are seeing this same issue now). It was in fact an issue with SAP Business Objects and where it was looking for the rasauditingw.dll.
    ****WARNING THIS IS DONE AT YOUR OWN RISK!!****
    I AM NOT RESPONSIBLE FOR DAMAGES TO YOUR PROGRAMS OR SYSTEM THIS FIX MAY CAUSE
    BACKUP YOUR SERVER OR TAKE A SNAP SHOT (VM) BEFORE ATTEMPTING ANY OF THE FOLLOWING
    We copied the rasauditngw.dll file into the system32 folder and the sysWOW64 folder and then renamed the original rasauditingw.dll to rasauditingw.dll.bak (Original file in this directory: C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise
    XI 4.0\win32_x86).
    So far so good. We have not seen any errors in the last couple of days since the fix. I hope this helps others who run into this mystery problem. Christen Steven was gracious enough to dig into this problem and quell my frustrations and issues with the 
    "crd.exe - Entry Point Not Found" error" "
    We haven't seen any issue with our CRD server since we moved the copies of that .dll file over into our sys32 folder and sysWOW64 folder on the CRD server (our server where the Christian Steven software resides).

  • Can anyone tell me in detail how to install SharePoint 2013?

    I know it requires Windows Server Operating System, so  installed it on my VMWare (can it be installed on Win8 by any any any chance, highly unlikely)
    When I installed SharePoint Foundation 2013, it extracted files and then opened cmd prompt which opened 'splash.hta' in visual studio. I can't get past it!
    What are the pre-requisites???
    Please tell me in detail how to install Sharepoint on a laptop, if it is possible. 
    I am learning it these days, and want to try on it on my laptop.

     know it requires Windows Server Operating System, so  installed it on my VMWare (can it be installed
    on Win8 by any any any chance, highly unlikely)  
    Inder : Yes you can install it on VMware but VM's operating system should be windows server 2008 r2 or
    Windows server 2012.  Installing SharePoint 2013 preview on Windows 8 is unsupported, although here:
    http://www.microsoft.com/en-us/download/details.aspx?id=30345 it's listed. You need to install on either Server 2008 R2 SP1 or Server 2012 RC
    When
    I installed SharePoint Foundation 2013, it extracted files and then opened cmd prompt which opened 'splash.hta' in visual studio. I can't get past it!
    Inder: can't say why is happening may be you dont have windows server. 
    What are the pre-requisites???
    Inder: Its better if you are connected to internet from the VM to download and install pre-requisites.
    It is a pain to manualy install it
    If this helped you resolve your issue, please mark it Answered

  • How to make SharePoint 2013 search only in document content?

    We are using SharePoint 2013 environment and are facing following issue while doing search in the document library.
     There is  one document library named “MYDOC” .and it has two columns name ‘DocTitle’ and ‘DocTag’.. Although we are able to perform search on basis of document metadata and content, however we only want to search through the content of documents
    in the library and not on the basis of document metadata (like ‘DocTitle’ or ‘DocTag’ columns). Is there a way to restrict search to document content only and not metadata?
    Excluding the column name will not help since, if the searched keyword is exists in metadata as well then that item of library will not come in result. Is there any way of writing query in such a way that only document content will get queried?
    -Aditya

    Addition to the above,
    Show or hide content from lists or libraries in search results
    As a site owner, you can decide whether items in lists and libraries on your site are included in search results. By default every list and library is set to include all items in search results.
     Note    To change this setting, you must have the Manage Lists permission level. The Designer and “Site Name” Owner groups contain this permission level. When you do not have Manage Lists permissions, the menus
    described in this procedure are not available.
    Navigate to the site that contains the list or library that you want to change.
    Locate and click the list or library you want to customize.
    Click Site Actions, and then click Site Settings.
    Under Site Administration, click Site Libraries and lists.
    Click an item from the list, for example, Customize “Shared Documents.”
    On the List Settings page, under General Settings, click
    Advanced settings.
    In the Search section, under Allow items from this document library to appear in search results, select
    Yes to include all of the items in the list or library in search result or
    No to exclude all items from search results.
    http://office.microsoft.com/en-in/sharepoint-server-help/enable-content-to-be-searchable-HA010379092.aspx

  • How to debug sharepoint 2013 provider hosted app?

    We developed SharePoint 2013 provider hosted app using MVC 5 Entity Framework of Database first and publish in Windows Azure site as well as deployed that project to our SharePoint app Catalog. We need to change Windows azure site so we
    changed to publish in  another Windows Azure site and deployed again to our SharePoint app Catalog. No problem the app is working after we changed Windows Azure site. I am new of this technology I faced so hard of changed
    existing Windows Azure site to New Windows Azure site. Please tell me how to debug the SharePoint Provider hosted app? Please tell me step by step process.
     Thanks in Advance.

    Hi,
    According to your description, you might want to know how to debug provider hosted app.
    To get a quick start, I would suggest you take a look at the link below about
    Debugging SharePoint Apps That Are Hosted In Windows Azure Web Sites:
    http://blogs.technet.com/b/speschka/archive/2013/11/25/debugging-sharepoint-apps-that-are-hosted-in-windows-azure-web-sites.aspx
    Another two similar articles for your reference:
    http://sharepointfieldnotes.blogspot.jp/2013/03/making-it-easy-to-develop-and-debug.html
    http://blogs.msdn.com/b/officeapps/archive/2013/01/03/debugging-remote-event-receivers-with-visual-studio.aspx
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • How to export SharePoint 2013 Calendar View to PPT or as an image?

    Greetings!
    I am working on a SharePoint 2013 event calendar and should be able to provide a capability to export my calendar view (day/week/month) as a PPT slide or as an image. I understand that OOB we can export the calendar list to Excel or open using MS Access.
    I had been exploring the option of using the Chart View Web Part which can be saved as an image (jpeg/bmp/png). Here are the pitfalls - Chart View WP does not support calendar view. At best, I am able to use the Gantt Chart Types, but having difficulty using
    Calendar list "Start Time" column for one of the axes. There is End Time and Duration columns available for selection, but not start time. Also, I am unable to define date range for my date in the x-axis. Right now I have an x-axis
    that spans over 40 years. Is there any way to confine the chart for a particular quarter or year.
    At this time, I am inclined to look at custom development approaches. Any suggestions regarding an approach will be really helpful.
    Thanks!

    Well, even if you want to go through "Export", it will be more manual work than taking a screenie. Unless of course you want to achieve it programmatically (am not sure what to do there).
    Another option could be to subscribe to the SharePoint Calendar from Outlook. That way you can eliminate the need for the PPT (?) and also enable your users/clients/management to have more clarity on how the dates stand vis-a-vis other stuff they have listed
    on their calendars.
    ----------------------- Sujay Sarma {Unbounded;}

Maybe you are looking for

  • I need to get email for this company. Please help me.

    Thanks Apple! you lost me like a good customer.

  • Connection between Oracle 9i and MS Sql Server 2005

    Hey Guys, I am hoping to create materialized view of data on a small sql server box using our oralce 9i cluster. Anyway, i have done this with mysql using the standard odbc dirvers and a dblink, but i am having trouble finding an odbc driver for the

  • N:1 Multi mapping issue at PI 7.1

    Hi Experts, I have 2 different source message types (824 & 997) to be mapped to target mail package (N:1 mapping). I have added both the source messages (provided xsd for 824 & 997 as External defination) under Tab "Signature" . Now when I go back to

  • Apache is not working

    I had installed apache and everything was ok, until I ran a program in c that when a browser sent request, it served a web page using sockets. After that, whenever I typed localhost, it showed me my Documents directory. Then I configured the files a

  • X Control Exec State Change with Panel Close

    I have an X Control that launches VIs dynamically and loads them into subpanels. If I put this X Control on a VI front panel and that VI has its panel closed, but that panel close event is unhandled so LabVIEW takes the default panel close behavior,