none
Sharepoint Online CSOM add list item RRS feed

  • Question

  • Hi,

    I am trying to perform a very basic operation of adding a list item to SharePoint online list using the following code :

    var context = GetUserContext();
    List userResponseList = context.Web.Lists.GetByTitle("UserResponseDetails");
    FieldLookupValue linkedLookupItem = new FieldLookupValue();
    
    linkedLookupItem.LookupId = 1;
    
    ListItemCreationInformation userResponseInfo = new ListItemCreationInformation();
    
    newUpdateItem = userResponseList.AddItem(userResponseInfo);
    
    newUpdateItem["LookupField"] = linkedLookupItem;
    newUpdateItem["MultilineText"] = "Some sample text";
    newUpdateItem[AttemptCount] = 1;
    
    newUpdateItem.Update();
    
    if (context.HasPendingRequest)
    {
         await context.ExecuteQueryAsync();
    }

    Using the above code, I am able update numeric fields, but Lookup, Multiline and single line text fields are not getting saved/updated to SharePoint Online.

    I am using .NET Core 2.1 for development.

    Please help!

    Thanks in advance,

    Cheers,

    Y

    Friday, December 14, 2018 11:17 AM

All replies