1

I'm trying to update properties of documents in my SharePoint site using C# code.

This is the code I'm using to get to the folder I need:

public SPArchiveBDI(string sharepointsite, string documentLibraryName)
{
    _sharePointSite = sharepointsite;
    _documentLibraryName = documentLibraryName;
    context = new ClientContext(SharePointSite);
    list = context.Web.Lists.GetByTitle(DocumentLibraryName);
    context.Load(list);
    context.Load(list.RootFolder);
    context.ExecuteQuery();
    root = list.RootFolder;
    context.Load(root);
    context.ExecuteQuery();

    customerFolder = root.Folders.GetByUrl("לקוחות");
    context.Load(customerFolder);
    context.ExecuteQuery();

    bDIFolder = customerFolder.Folders.GetByUrl("BDI");
    context.Load(bDIFolder);
    context.ExecuteQuery();
}

This code works fine.

My problem is with the code I'm using to update two properties in documents in that folder.

public void ChangeFileInBDI(string name, int WFID, int entityID)
{
    File doc = bDIFolder.Files.GetByUrl(name);
    context.Load(doc);
    context.ExecuteQuery();

    ListItem lst = doc.ListItemAllFields;

    lst["מספר תהליך"] = WFID;
    lst["EntityId"] = entityID;

    lst.Update();

    context.ExecuteQuery();
}

The name is the name of the document in the folder and the code actually finds it.

The code falls in the last row, where it says context.ExecuteQuery().

The error message says:

A first chance exception of type 'Microsoft.SharePoint.Client.ServerException' occurred in Microsoft.SharePoint.Client.Runtime.dll

Additional information: Column 'מספר תהליך' does not exists. Someone else may have deleted it. /TenDocuments

If there is a handler for this exception, the program may be safely continued.

My folder and document contain these properties and I have no idea why my code falls.

Can someone tell me where my problem is?

Thank you in advance!

  • Check the internal name of the column that you are updating....whether it's same as provided in your code or not? – Dikesh Gandhi Jun 7 '16 at 7:54
  • The names are equal – itzick binder Jun 7 '16 at 11:17
0

My problem was the names on the columns.

Instead of naming them like I see them on the SharePoint site, I should have named them as the encoded name they have: "_x05de__x05e4__x05e8.....".

Now it works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.