1

I would like to add a column to a sharepoint list which is created in visual studio. am not using list definition, only list instance. I could open the list xml and add new items, but how can I add new column to the list? what's the best approach?

1 Answer 1

2

As always in such situations, the best option IMO is to avoid using declarative (XML) approaches to use instead a feture event receiver and C# code (unless you're developping an App).

Here's a good start: https://stackoverflow.com/questions/19548874/automatically-creating-a-list-and-a-folder-when-activating-a-feature-in-sharepoi/19566648#19566648. The code is to create a list, but it is the same concept as to add a field on an existig list.

2
  • thanks Evariste, in my case, I have a sharepoint hosted app, so what's the solution in this case?
    – Natalie
    Commented Dec 13, 2015 at 22:08
  • Add JavaScript code on the main page of your SharePoint hosted app. That code would check if the field already exists or not. If not, it tries to create it. Code to create a column on a list from JavaScript on the App Web can found at sharepoint.stackexchange.com/a/86502/35604.
    – Evariste
    Commented Dec 14, 2015 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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