This project has moved and is read-only. For the latest updates, please go here.

Add Column in a list programmatically?

Jun 21, 2012 at 7:42 PM
Edited Jun 21, 2012 at 8:23 PM

I see that there is an UpdateList function but I am not really able to find any useable examples of how this works... any hints?

All I am trying to do is to add a new column to a SP list (SP 2007), using javascript.



Jun 21, 2012 at 8:25 PM

Right after I poseted this I saw a 'delete' example that was basically what I needed. Here is my own little example though, which maybe we can add to the examples on the site:

var newFields = '<Fields><Method ID="2"><Field Type="Text" DisplayName="Field3_Name_tmp" FromBaseType="TRUE" MaxLength="255" Description="DescriptionABC" /></Method></Fields>';

operation: "UpdateList",
listName: "MyListHere",
updateFields: "",
newFields: newFields,
deleteFields: "",
listVersion: "",
async: false,
completefunc: function (xData, Status){}

Jun 22, 2012 at 12:58 PM
Edited Jun 22, 2012 at 12:58 PM

I've got links to each of the Web Services pages on MSDN in the SDK in the documentation. On those pages, you'll see what each operation expects you to provide to work.


Jun 22, 2012 at 4:32 PM

... Now I see it. In my link frenzy yesterday I blew right past that. I was *that guy* who didnt read the documentation properly.


Thanks :)

Jun 22, 2012 at 4:47 PM

You don't want to be "that guy". ;-)


Feb 11, 2013 at 10:23 PM
How about adding a Site Column to a list using SPServices? I am trying to add a Lookup Column, which I made as a Site Column referencing a list in the root site, to a lists in subsites. I have tried using:
 <Field Name="New List Column" DisplayName="New List columns" Type="Lookup" List="{lookup-list-guid}" />
This worked perfectly for lookup lists in the subsites, but not for a lookup list located in the root list.

Any help/insite is appreciated.
Feb 13, 2013 at 5:22 AM

I found this post, which should get you there:
Add an existing site column to a list using Web services