2

I am trying to perform a basic operation,updating a column in a list item of a list.Following is the code ,

    List oList = clientContext.Web.Lists.GetByTitle("HomePageTab"); 
    ListItem oListItem = oList.GetItemById(1);
    oListItem["Link Location"] = "https://www.google.com";
    oListItem.Update();
    clientContext.ExecuteQuery();

When i execute this code.I get following error.

{"Column 'Link Location' does not exist. It may have been deleted by another user. /sites/ModusDev/Lists/HomePageTab"}

The issue is the column is available but still unable to update the empty column for the selected listitem.What might be the reason.

I have a url having characters more than 256 which is not accepted when entering in linklocation column. So I am trying to enter the url to link location programatically using CSOM.

2

Error reason

 oListItem["Link Location"] = "https://www.google.com";

In above code Link Location is the display name of your column. Use internal name instead.

Update#1

You won't be able to enter 255+ characters using CSOM also.

  • Ok ,may i know how to find the internal name of the column? – kaarthick raman Feb 24 '16 at 6:10
  • Go to list settings---> click on the column----> find internal name in the end of the url in browser – Atish Dipongkor - MVP Feb 24 '16 at 6:13
  • I have a url generated for a azure website which exceeds 256 characters. Is there any way to optimize the URL? @atish – kaarthick raman Feb 24 '16 at 6:28
  • There is HyperLink type column. you can use it. Anyway now accept the answer. – Atish Dipongkor - MVP Feb 24 '16 at 6:39
1

You are trying to update a column Link Location, @Atish is correct that this is a display name. And while you try to update any item you need to refer the internal names.

SharePoint has its own logic of maintaining the internal names. Most often the spaces in the names are converted to _x0020_. So instead of your code try below.

oListItem["Link_x0020_Location"] = "https://www.google.com";

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.