Adding a Site Column to a list

Oct 20, 2015 at 3:49 PM
Hi,

I have created a new site column using the UpdateColumns method of the Webs web service. However, I am having issues with adding this newly created site column to a SharePoint List using JavaScript? Is it possible? Any help appreciated..
Coordinator
Oct 28, 2015 at 4:18 PM
I believe you should be able to do this using UpdateList.
https://spservices.codeplex.com/wikipage?title=Lists

Is that what you've tried?

M.
Nov 4, 2015 at 9:26 PM
Hi Marc,

I tried using the UpdateList to add a preexisting site column to a list using the following code. However, it creates a new column (not linked to the site column) in the list itself. Supplying the GUID of the site column was the only thing I could think of to link this new list column to the site column. But I am confident that this new column is not the site column because it does not carry the default value supplied on the site column when being created like this. However, when I manually create it using UI the default value is there.

$().SPServices({
operation: "UpdateList",
listName: "ltest",
newFields: "<Fields><Method ID='1'><Field Type='Text' Name='Test' DisplayName='Test'  ID='{443a4689-fea4-494a-a690-1a9a13f5fd02}'></Field></Method></Fields>"
});
Nov 4, 2015 at 10:00 PM
Update: Issue resolved. The above does work. It just does not take the default values provided on the site column as I was not providing it. However, after creating the list column, when I update the default value of the site column and push the updates to all the children instances, it does update the newly created list columns' default value.

Thank you for your attention!!!
Coordinator
Nov 4, 2015 at 10:15 PM
Whew. Glad to hear it worked.

M.