Item.SystemUpdate for Client Object Model in sharepoint 2010

I have a javascript that modifies a column/field in the list item when opened. However, this changes the Last Modified By field of the item.
is there a SystemUpdate method for Client Object Model?
----------------------- Sharepoint Newbie

I got a work around for this problem..
Before updating the Modified, Modified By values, First we need to Disable the version settings for document library. Once the fields updated then again we need to enable the version settings. 
find the updated code below..
                                      //Disable Version settings for DOC LIB
before update Metadata
                                        _List.EnableVersioning
= false;
                                        _List.Update();
                                        _cContext.ExecuteQuery();
                                       ListItem item = newFile.ListItemAllFields;
                                       _cContext.Load(item);
                                        //Updating Metadata Created,
CreatedBy, Modified, Modified By
                                         item["Created"]
= "8/10/2013 7:04 PM";
                                         item["Author"] = CreatedUserValue;
                                         item["Modified"] = "8/10/2013 7:04 PM";
                                         item["Editor"] = ModifiedUserValue;
                                         item.Update();
                                        _cContext.ExecuteQuery();
                                        //Enable Version settings
for DOC LIB after update Metadata
                                           _List.EnableVersioning
= true;
                                          _List.Update();
                                        _cContext.ExecuteQuery();
Rajendra

Similar Messages

  • Advantages and Disadvantages of Client Object Model in sharepoint 2013

    I need Advantages and Disadvantages of Client Object Model in sharepoint 2013
    like below in javascript. Users will have read/edit and approve access to the list.
      var clientContext = new SP.ClientContext.get_current();
           var oList = clientContext.get_web().get_lists().getByTitle('Workflow Tasks');
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

    Thanks 
    AlexanderShelopukho for
    right answer!
    Alex-
    I do not need comparison- 
    I need Advantages and Disadvantages of Client Object Model in sharepoint 2013
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

  • Client object model in SharePoint 2013

    Hi,
    I have installed .Net 2012 and want to create one client object model .But SharePoint is not installed in my system.So how i will get the SharePoint templates in the .net and how i  am able to do this.
    Please help
    Thank you

    Hi,
    Thanks for reply.
    But i am working in client machine and i have to create app using client object model and i have no access to the server.
    As per your answer, you want say i have to install SharePoint in my client system ?
    Then only i get the sharepoint templates in the .Net ?

  • Add attachments to List Item using JavaScript Client object model in SP2010

    Hi All ,
    I have created custom form for submitng data in list using javascript client object model/jquery .
    Now I want to add option to uplaod multiple attachments to that list item also .
    Is there option with client object model for uplaoding attachment.
    Thanks
    M
    Manesh G

    Can you try this and let me know
    using (SPSite _site = new SPSite(SPContext.Current.Site.Url))
        using (SPWeb _web = _site.OpenWeb())
         //Let's suppose your Item Id is 1
         int ItemId = 1;
         SPList  oList = _web.Lists["EmployeeList"];
         SPListItem  _item = oList.GetItemById(ItemId);
         if (FileUpload1.HasFile)
               _web.AllowUnsafeUpdates = true;
              Stream fs = FileUpload1.PostedFile.InputStream;
              byte[] _bytes = new byte[fs.Length];
              fs.Position= 0;
              fs.Read(_bytes, 0, (int)fs.Length);
              fs.Close();
              fs.Dispose();
              _item.Attachments.Add(FileUpload1.PostedFile.FileName, _bytes);
              _item.Update();
              _web.AllowUnsafeUpdates = false;

  • Is it possible to change the title of a webpart using client object model/c#/sharepoint online

    Hi folks!
    I have been busted my butt trying to Write a program changing the title of an existing webpart on on of our subsites on SharePoint online. But I keep getting an error in the very last context.executequery. Tried a bunch of different approaches, but I can't
    make it work. Before I start posting code; I Wonder if anyone have ever done this?
    Its a plain Windows form application, using Visual studio Express and the Client Object model. (Listsing the titles of the webparts Works but changing titles seem impossible. Thought it might be a checkin/out problem but it doesn't make a difference).
    Any help would be highle appreciated.
    Lars

    It depends: are you using the default style for Text Captions? In that case you can change the default style in the Object Style Manager and have it applied to all Captions.
    Or you can change one text caption, and in its Properties panel choose the option 'Save Changes to existing style' from the menu top right (see screenshot). Both methods will work if you didn't override the default Caption Style for those captions. Beware: Quizzing objects can use another style.

  • Attachment size client object model in sahrepoint 2010

    hI
        Here is my code 
    ExecuteOrDelayUntilScriptLoaded(getWebProperties, "SP.js");
    var  attachmentFiles;
    function getWebProperties()
     var itemId=5;
     var list;
    var item;
     var file; 
                  var ctx = SP.ClientContext.get_current();            
                    var webSite = ctx.get_web();
                      var attachmentFolder=webSite.getFolderByServerRelativeUrl('Lists/xxx/Attachments/'+itemId);
                       attachmentFiles= attachmentFolder.get_files();
                        ctx.load(attachmentFiles);
                        ctx.executeQueryAsync(Function.createDelegate(this,this.onSuccess),Function.createDelegate(this,this.onFailed));                 //  ctx.load(attachmentFolder);
    function  onSuccess(sender, args)
    alert('success'); 
        alert(attachmentFiles.get_count());
    for(var p=0;p<this.attachmentFiles.get_count();p++)
               var file = attachmentFiles.itemAt(p);     
                var filename = file.get_name(); 
              //debugger;
                alert(filename);  
       // need the file size here 
    How do i get the Total attachment file size here .There are no properties to  get the attachment size .Help much appreciated Thanks in advance 
    nain1987

    Check if below helps
    http://sharepoint.stackexchange.com/questions/12652/get-total-size-of-attached-files-on-all-list-items-in-sharepoint-2007with-powers
    function GetListSize($List)
    [long]$listSize = 0
    $allAttachmentsFolder = $List.RootFolder.SubFolders["Attachments"]
    foreach ($listItem in $List.Items)
    $listItemAttachments = $listItem.Attachments
    $attachmentsFolder = $allAttachmentsFolder.SubFolders[$listItem.ID]
    foreach($file in $listItemAttachments)
    $listSize += $attachmentsFolder.Files[$file].Length
    $totalInMb = ($listSize/1024)/1024
    $totalInMb = "{0:N2}" -f $totalInMb
    return $totalInMb
    http://social.technet.microsoft.com/Forums/en-US/e5d2ff3d-01c7-4cc0-a081-29a4dfbb0fad/getting-the-sharepoint-list-attachment-size-using-javascript?forum=sharepointcustomizationlegacy
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/c745bd1c-cbcb-4523-bdac-7c8d62d1d3ff/show-the-size-of-attachments-is-sharepoint-2007?forum=sharepointcustomizationlegacy

  • Client Object Model Sharepoint 2010

    We are using client object model in sharepoint 2010
    When we excute the ExcuteQuery method of clinet obejct model we are getting following error
    The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again
    Girish

    Hi ,
    A FormDigest control has to be included to create a digest for security validations when performing some modifications to SharePoint data. It adds a security token inside your page based on user, site and time. Once the page is posted back the security token
    is validated. Once the security token is generated it’s valid for a configurable amount of time. 
    for more info check the below links
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.formdigest.aspx
    http://ranaictiu-technicalblog.blogspot.com.au/2010/02/sharepoint-2010-client-object-model-for.html
    if above link is not working, use below function before execute the query.
    function CustomUpdateFormDigest()
    if(window._spPageContextInfo != null)
    var $v_2 = window._spPageContextInfo;
    var $v_3 = $v_2.webServerRelativeUrl;
    var $v_4 = window._spFormDigestRefreshInterval;
    UpdateFormDigest($v_3, $v_4);
    CustomUpdateFormDigest();
    Please mark it as an answer/helpful if it is useful.
    Thanks
    Mahesh

  • CAML Query to get specific item in folder based on dropdown value using Javascript client object model

    Hi,
    I am using the Javascript Client object model.
    I have a custom list and a custom document library.
    Custom list contains 2 columns - dlName , dlValue
    The document library contains 2 folders - "folder1" ,  "folder2" and contains some images.
    The image name starts with the "dlValue" available in the custom list
    I am using a visual webpart and using javascript client object model.
    I am trying to achieve the below functionality:
    1) Load a dropdown with the custom list.
    2) set the image based on the value in dropdown.
    I have achieved the first option, I have set the dropdown, but not sure how to query the folder and set the image.
    Below is the code i have used so far:
    //In Visual webpart
    <select id="ddlTest" >
    </select>
    <br/>
    <div id="PreviewLayer">
    <img id="imgPlaceHolder" runat="server" alt="Image" title="imgPlaceHolder" src=" " />
    </div>
    // In Javascript file
    function RenderHtmlOnSuccess() {
    var ddlTest = this.document.getElementById("ddlTest");
    ddlTest.options.length = 0;
    var enumerator = this.customListItems.getEnumerator();
    while (enumerator.moveNext()) {
    var currentItem = enumerator.get_current();
    var dropdownValue = currentItem.get_item("dlValue");
    ddlTest.options[ddlTest.options.length] = new Option(currentItem.get_item("dlName"), dropdownValue);
    setImage(dropdownValue); // Not sure how to query the folder and set the image based on value.
    // Also if dropdown value is changed, corresponding image should be shown
    How to query the folder and based on dropdown value, show the image? Also, how to handle the dropdown value change?
    Thanks

    Hi,
    Here are two links for your reference:
    Example of how to Get Files from a Folder using Ecmascript \ Javascript client object model in SharePoint 2010
    http://sharepointmantra.wordpress.com/2013/10/19/example-of-how-to-get-files-from-a-folder-using-ecmascript-javascript-client-object-model-in-sharepoint-2010/
    SP2010 JSOM Client Object Model: How to get all documents in libraries including all folders recursively
    http://sharepoint.stackexchange.com/questions/70185/sp2010-jsom-client-object-model-how-to-get-all-documents-in-libraries-including
    In SharePoint 2013, we can also use REST API to achieve it.
    http://msdn.microsoft.com/en-us/magazine/dn198245.aspx
    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

  • How to activate Custom Feature in SharePoint 2010 using Client Object model

    I am trying to Activate a custom feature using Client Object Model in SharePoint 2010. Here is the code I used. When I execute the code, I got the error "Feature with Id 'xx' is not installed in this farm, and cannot be added to this scope while
    creating site collection". Can anyone help?
    ClientContext clientContext = new ClientContext(spURL);
    //GUID of the custom feature                    
    Guid districtFeatureId = new Guid("5b3529de-5045-46da-af87-8d2e32c121a7");
    Site clientSite = clientContext.Site;
    FeatureCollection clientSiteFeatures = clientSite.Features;
    clientContext.Load(clientSiteFeatures);
    clientContext.ExecuteQuery();
    //Activate the feature
    clientSiteFeatures.Add(districtFeatureId, false, FeatureDefinitionScope.Site);
    clientContext.ExecuteQuery();

    Hi shil chan,
    When you activate a feature on the site collection, the feature should be scoped to site or farm, the error message shows it cannot find the specific feature, this will happen when you have a feature in web
    scope or the feature isn’t installed.  
    So, to troubleshooting this issue:
    Verify whether the feature is scoped to web. Please go to
    Site Setting->Site Features . If the feature is a web scope feature, then add the feature to webfeatures.
    Make sure the feature is installed correctly.
    Please inform me freely if you have any questions.
    Thanks

  • How to change 'Modified By' column value when a new file is uploaded in SharePoint 2013 using Client Object Model?

    I want to change 'Modified By' column value of a file that is being uploaded using Client Object Model in SharePoint 2013. The problem is that the version of the file is changing. Kindly help me. The code that I am using is:
    using (System.IO.Stream fileStream = System.IO.File.OpenRead(m_strFilePath))
        Microsoft.SharePoint.Client.File.SaveBinaryDirect(m_clientContext, str_URLOfFile, fileStream, true);
        Microsoft.SharePoint.Client.File fileUploaded = m_List.RootFolder.Files.GetByUrl(str_URLOfFile);
        m_clientContext.Load(fileUploaded);
        m_clientContext.ExecuteQuery();
        User user1 = m_Web.EnsureUser("User1");
        User user2 = m_Web.EnsureUser("User2");
        ListItem item = fileUploaded.ListItemAllFields;
        fileUploaded.CheckOut();
        item["UserDefinedColumn"] = "UserDefinedValue1";
        item["Title"] = "UserDefinedValue2";
        item["Editor"] = user1;
        item["Author"] = user2;
        item.Update();
        fileUploaded.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);
        m_clientContext.ExecuteQuery();

    Hi talib2608,
    Chris is correct for this issue, when calling update using ListItem.update method, it will increase item versions, using SystemUpdate and UpdateOverwriteVersion will update the list item overwrite version.
    these two methods are not available in CSOM/REST, only server object model is available for this.
    Thanks,
    Qiao Wei
    TechNet Community Support

  • SharePoint 2013 implement simple logout button which do not redirect to default sign out page using JavaScript client object model

    I am using windows authentication in my web application.
    My requirement is to implement a sign out button which will sign out the user without having him to close the browser and application should not ask him to login again.
    I tried following two options:
     1. Redirecting the user to default signout.aspx page " /_layouts/15/SignOut.aspx "
     2. Using "Sign In as a different user" URL " /_layouts/15/closeConnection.aspx?loginasanotheruser=true "
    In first case, user is redirected to default sign out page but he can press "Go Back to Site" link to revisit the site. Another major issue is that the user has to close the browser to sign out from the application completely, which is not desirable
    in my project requirement.
    In second case, the the current user is signed out of the application but if the user has saved the password in browser, he gets signed in automatically to the application.
    I also came across the solution where we replace the default sign out page with a custom sign out page, but I am not sure whether it can be implemented using JavaScript Client Object Model of SharePoint.

    Hi 
    I'm basically looking for the exact answer for the query.
    Meanwhile you need to go through the link mentioned below in order to understand how to do it.
    Debugging and Logging Capabilities in SharePoint 2010
    Indul Hassan
    Microsoft Community Contributor
    http://www.indulhassan.com
    You Snooze.. You Lose !!

  • Client Object Model in Visual Webpart

    Hi
    I am new to Client Object Model.I've to create a visual web part in SharePoint 2013 via Client Object Model using
    SandBoxed solution.
    i did following.
    1-Created empty sharepoint project
    2-added two dlls for Client Object Model in the project
    Microsoft.SharePoint.Client
    Microsoft.SharePoint.Client.Runtime
    3-in the visual webpart .ascx file i just created asp label as  below
    <asp:Label ID="label1" runat="server"></asp:Label>
    4- in the visual webpart .cs file i write a client object model code to show title items in the label from the "Test" list as below.
    5-when i deploy the code it deploys successfully,but when i try to insert this web-part on to the page it shows errors
    as below.
    Please tell me what am i doing wrong.Urgent help required.

    Yes,deployed as sandbox solution.Actually i want to create a visual webpart in Sharepoint 2013 using Client Object Model. How can i do this,i followed below steps.
    1-Created empty sharepoint project
    2-added two dlls for Client Object Model in the project
    Microsoft.SharePoint.Client
    Microsoft.SharePoint.Client.Runtime
    3-in the visual webpart .ascx file i just created asp label as  below
    <asp:Label ID="label1" runat="server"></asp:Label>
    4- in the visual webpart .cs file i write a client object model code to show title items in the label from the "Test" list as below.
    using Microsoft.SharePoint.Client;
    using System;
    using System.ComponentModel;
    using System.Web.UI.WebControls.WebParts;
    namespace SharePointProject2.VisualWebPart1
        [ToolboxItemAttribute(false)]
        public partial class VisualWebPart1 : WebPart
            // Uncomment the following SecurityPermission attribute only when doing Performance Profiling on a farm solution
            // using the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
            // for production. Because the SecurityPermission attribute bypasses the security check for callers of
            // your constructor, it's not recommended for production purposes.
            // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
            public VisualWebPart1()
            protected override void OnInit(EventArgs e)
                base.OnInit(e);
                InitializeControl();
            protected void Page_Load(object sender, EventArgs e)
                ClientContext context = new ClientContext("http://spsiteURL");
                List testList = context.Web.Lists.GetByTitle("Test");
                CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
                ListItemCollection items = testList.GetItems(query);
                context.Load(items);
                context.ExecuteQuery();
                foreach (ListItem listItem in items)
                    label1.Text = label1.Text + ", " + listItem["Title"];
    If this is not the correct way then how can i  use client object model to get sharepoint list items.Please mention.

  • Conflict between Client object model and Item Updated Event Receiver in sharepoint 2010

    Hello All,
    As per my requirement I have a two custom list.
    Agent Details
    Port Name
    Agent Details contains Agent code, Port Name,  email, address and phone of Agent. Its possible that one Agent Code is connected with multiple Port Name.
    Basically what I am doing is I am getting port name connected with Agent code, using jquery and bind those values with check box(using javascript created dynamically) and bind all with Div tag.
    Now when my custom edit form of Agent list open up it shows me different port name binding with checkbox group.
    when user select the check box and click confirm button my clicent object model script will run and add this selected value into Port Name list. 
    After confirm one more button named Save will enable asking user to edit the email, phone or address value and when I click on save my Item updated event fires which update the values of the selected port name(These port name I am getting from port
    name list) to Agent Details custom list.
    Now when I am trying to update the values my event receiver fires or some times it got stuck(not firing). So could you please help me the possible alternative for this requirements.
    Can we user the Ecma Script(Client object model to preserve the value of selectec port) and Item updated event receiver on the same time?
    Is anything am doing wrong then please guide me.

    Hi,
    As I understand, when you updated values in the agent details list the Item updated event receiver got stuck sometimes.
    The item update event receiver will fire after the item has been saved, and the client object model script or the Ecma Script runs before the item is saved, so there is no conflict between the client object model script and item update event receiver.
    You could find out the reason about the item update event receiver gets stuck by debugging the event receiver.
    When you want to debug your event receivers, you have to attach to OWSTIMER.EXE and wait till they are executed. You can control this behavior using the Synchronization attribute. Also, if you’re looking for an easy way to debug an event receiver without
    having to manually attach a debugger to your code, you can use the System.Diagnostics.Debugger.Launch() method.
    The articles below are about how to debug in the event receiver in SharePoint 2010.
    http://sharepoint-kings.blogspot.jp/2013/02/debugging-event-receivers-in-sharepoint.html
    http://chakkaradeep.com/index.php/event-receivers-in-sharepoint-2010/
    http://sharesaint.com/?p=77
    Best regards,
    Sara Fan
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Issue in adding new items to a O365 SharePoint Online List having lookup columns (Client Object Model)

    I have two Lists i.e. Publisher and Products in my SharePoint Online site. They are having the following structures:
    1. Publisher:
    Publisher (Single line of txt)
         A1
         A2
         A3
         A4
         A5
         A6
    2. Products:
    Publisher (lookup to the above column)       
    ProductName (Single line of txt)
         A1                                                                   Apple
         A2                                                                   Samsung
         A3                                                                   Nokia
    And I have an excel file named Products.xlsx in my local machine which has the following data:
    Publisher        ProductName
         A1                   Apple
         A2                   Samsung
         A3                   Nokia
         A4                   Motorola
         A5                   LG
         A6                   HTC
    Now I have written the below client-side (CSOM) code to fetch the data from the Excel and update the corresponding fields in the Products table:
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Web;
    using System.IO;
    using System.Data;
    using System.Data.OleDb;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Client;
    using File =
    Microsoft.SharePoint.Client.File;
    using System.Security;
    namespace ExcelToSP
        public class
    ExcelToSP
            //Main function to get the command line values and invoke the getSPList function to pull SP List data
            public
    static void Main(string[] args)
                //Instantiate Class object
                ExcelToSP p
    = new ExcelToSP();
                try
                    p.LoadExcelData();
    //Exit with Sucess code
    Environment.Exit(0);
                catch
    (Exception ex)
    //Invoke writeErrorLog function to log the exception details
    //p.WriteErrorLog(ex);
            public
    void LoadExcelData()
                try
                string fileName
    = @"E:\Products.xlsx";
                string fileExtension
    = Path.GetExtension(fileName).ToUpper();
                string connectionString
    = "";
                 if
    (fileExtension == ".XLS")
                    connectionString
    = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"
    + fileName + "'; Extended Properties='Excel 8.0;HDR=YES;'";
                else
    if (fileExtension ==
    ".XLSX")
                    connectionString
    = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='"
    + fileName + "';Extended Properties='Excel 12.0 Xml;HDR=YES;'";
                if
    (!(string.IsNullOrEmpty(connectionString)))
    string[] sheetNames =
    GetExcelSheetNames(connectionString);
    if ((sheetNames !=
    null) &&
    (sheetNames.Length
    > 0))
    DataTable dt = null;
    OleDbConnection con =
    new OleDbConnection(connectionString);
    OleDbDataAdapter da =
    new OleDbDataAdapter("SELECT * FROM ["
    + sheetNames[0]
    + "]", con);
                        dt
    = new DataTable();
                        da.Fill(dt);
    InsertIntoList(dt,"Products");
                catch
    (Exception ex)
    throw ex;
            private
    string[] GetExcelSheetNames(string strConnection)
                var connectionString
    = strConnection;
                String[] excelSheets;
                using
    (var connection =
    new OleDbConnection(connectionString))
                    connection.Open();
    var dt = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
    null);
    if (dt ==
    null)
    return null;
                    excelSheets
    = new String[dt.Rows.Count];
    int i = 0;
    // Add the sheet name to the string array.
    foreach (DataRow row
    in dt.Rows)
                        excelSheets[i]
    = row["TABLE_NAME"].ToString();
                        i++;
                return excelSheets;
            private
    void InsertIntoList(DataTable listTable,
    string ListName)
                try
    string username = "[email protected]";
    string pwd = "contoso@1234";//this.Dts.Variables["password"].Value.ToString();
    ClientContext clientContext =
    new ClientContext("https://contoso.sharepoint.com/teams/myPOC/");
    SecureString password =
    new SecureString();
    char[] decryptpwd = pwd.ToCharArray();
    foreach (char c
    in decryptpwd)
                        password.AppendChar(c);
                    clientContext.Credentials
    = new SharePointOnlineCredentials(username, password);
                    clientContext.ExecuteQuery();
    //Setting SiteURL Client context
    Web web = clientContext.Web;//
                    clientContext.Load(web);
                    clientContext.ExecuteQuery();
    List lstProductFamily = web.Lists.GetByTitle("Products");
    for (int iRow
    = 0; iRow < listTable.Rows.Count; iRow++)
    ListItemCreationInformation itemCreateInfo =
    new ListItemCreationInformation();
    ListItem newItem = lstProductFamily.AddItem(itemCreateInfo);
    //FieldLookupValue flv = newItem["Publisher"] as FieldLookupValue ;
    //string lkup = flv.LookupValue;
    //int valueid = 0;
    //valueid = flv.LookupId;
                        newItem["Publisher"]
    = Convert.ToString(listTable.Rows[iRow][0]);
                        newItem["ProductName"]
    = Convert.ToString(listTable.Rows[iRow][1]);
                        newItem.Update();
                        clientContext.ExecuteQuery();
                catch
    (Exception ex)
    throw ex;
    But I'm getting the following error on running the above code "Invalid data has been used to update the list item. The field you are trying to update may be read only." 
    Can anybody please help me out?

    Hi,
    According to your description, my understanding is that you want to update data to look up field.
    I have a test about updating look up field using Client Object Model in my environment. lookup field will accept an array to set the field value.
    Here is the code snippet:
    Microsoft.SharePoint.Client.ClientContext ctx = new ClientContext("http://sp2013sps/sites/test/");
    if (ctx != null)
    List list = ctx.Web.Lists.GetByTitle("List3");
    ListItem itemToUpdate = list.GetItemById(1);
    ctx.Load(itemToUpdate);
    ctx.ExecuteQuery();
    FieldLookupValue newLookUpField = new FieldLookupValue();
    newLookUpField.LookupId = 3;
    FieldLookupValue newLookUpField1 = new FieldLookupValue();
    newLookUpField1.LookupId = 4;
    FieldLookupValue[] newarr = { newLookUpField, newLookUpField1 };
    itemToUpdate["lookup"] = newarr;
    itemToUpdate.Update();
    ctx.Load(itemToUpdate);
    ctx.ExecuteQuery();
    Best regards
    Patrick Liang
    TechNet Community Support

  • Unable to get the SharePoint 2013 List names using Client object model for the input URL

    Please can you help with this issue.
    We are not able to get the SharePoint 2013 List names using Client object model for the input URL.
    What we need is to use default credentials to authenticate user to get only those list which he has access to.
    clientContext.Credentials = Net.CredentialCache.DefaultCredentials
    But in this case we are getting error saying ‘The remote server returned an error: (401) Unauthorized.’
    Instead of passing Default Credentials, if we pass the User credentials using:
    clientContext.Credentials = New Net.NetworkCredential("Administrator", "password", "contoso")
    It authenticates the user and works fine. Since we are developing a web part, it would not be possible to pass the user credentials. Also, the sample source code works perfectly fine on the SharePoint 2010 environment. We need to get the same functionality
    working for SharePoint 2013.
    We are also facing the same issue while authenticating PSI(Project Server Interface) Web services for Project Server 2013.
    Can you please let us know how we can overcome the above issue? Please let us know if you need any further information from our end on the same.
    Sample code is here: http://www.projectsolution.com/Data/Support/MS/SharePointTestApplication.zip
    Regards, PJ Mistry (Email: [email protected] | Web: http://www.projectsolution.co.uk | Blog: EPMGuy.com)

    Hi Mistry,
    I sure that CSOM will authenticate without passing the
    "clientContext.Credentials = Net.CredentialCache.DefaultCredentials" by default. It will take the current login user credentials by default. For more details about the CSOM operations refer the below link.
    http://msdn.microsoft.com/en-us/library/office/fp179912.aspx
    -- Vadivelu B Life with SharePoint

Maybe you are looking for