Is there any way to dynamically add metadata in the upload file. I am using the following code in this regard.

File uploadFile = context.Web.GetFileByServerRelativeUrl(location);
//check out to make sure not to create multiple versions
if (!list.ForceCheckout)

//setting metadata here
uploadFile.ListItemAllFields["Status"] = "In-Progress";

//overwrite to make sure not to create multiple versions
uploadFile.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);

Upon running above code, i am getting this error:

Column 'Status' does not exist. It may have been deleted by another user.

Now is there any way to dynamically create it programmatically because i preferably don't want to create it using designer?


For adding status column :

            List list = web.Lists.GetByTitle(listname);
            Field fild = web.Fields.GetByInternalNameOrTitle("Status");

Try with internal name of status column:

uploadFile.ListItemAllFields["_Status"] = "In-Progress";

| improve this answer | |
  • Still the same error. – Furqan Safdar May 27 '14 at 9:33
  • At what line you are getting error. There are 2 status columns in sharepoint. One with static name "_Status" and one with "DecisionStatus". You can try with 2nd one. – Aanchal May 27 '14 at 9:51
  • So you have not added the status column in sharepoint library? – Aanchal May 27 '14 at 9:58
  • First add the status column then update. I have added the code to add create site column – Aanchal May 27 '14 at 10:10

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.