Use CSOM to create a Site column of type "enterprise keyword"

I have successfully created site columns using CSOM.
When I look at the available types of site columns I can see
http://office.microsoft.com/en-us/sharepoint-server-help/site-column-types-and-options-HA010302196.aspx
But there is nothing similar to what you can do when you go into list settings and say "Add an enterprise keywords column and enable keyword synchronization"
What is the data type for the enterprise keywords column? why should it be directly added into the list via the UI... but not via a site column?
val it: unit=()

Hi,
The following code(Client Object Model) for your reference:
static void Main(string[] args)
string siteURL = "http://siteurl";
ClientContext context = new ClientContext(siteURL);
//specific user
NetworkCredential credentials = new NetworkCredential("username", "password", "domain");
context.Credentials = credentials;
FieldCollection fields = context.Web.Fields;
Field field = fields.GetByTitle("Enterprise Keywords");
context.Load(field);
context.ExecuteQuery();
//field schema xml
string fieldSchema=field.SchemaXml;
//update the schema of Enterprise Keywords field
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(fieldSchema);
XmlNode node=xmlDoc.SelectSingleNode("Field");
XmlElement Xe = (XmlElement)node;
Guid fieldID = Guid.NewGuid();
Xe.SetAttribute("DisplayName", "Enterprise Keywords1");
Xe.SetAttribute("StaticName", "TaxKeyword1");
Xe.SetAttribute("Name", "TaxKeyword1");
Xe.SetAttribute("ID", "{" + fieldID + "}");
fieldSchema = xmlDoc.InnerXml;
//add this field to the field collection
fields.AddFieldAsXml(fieldSchema, false, AddFieldOptions.DefaultValue);
context.ExecuteQuery();
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support

Similar Messages

  • How to create a site column through Visual Studio 2010?

    I was trying to create lists, content type and site columns through Visual Studio 2010. But I could not figure out how to add site column? What item do I need to add for this and what kind of coding is to be done?

    Try this
    1. Create a Empty project in Visual studio.
    2.The Empty SharePoint Project template does not include any Features in the Features folder. To add a new Feature to this project, right -click the Features folder, and click Add Feature. This adds a new Feature component to the folder; double – click the
    Feature1 icon in Solution Explorer to modify the Feature ’ s
    metadata using the Feature designer. The Title and Description values appear on the Features pages in Site settings. It is a good idea to make these values
    descriptive so that administrators will know what they are adding to the site when they activate the feature.
    The feature ’ s scope determines where the feature can be activated within SharePoint. Please Note – Certain components, such as site columns, content types, Master pages, and Page Layouts, are installed at the site collection level and made available to all
    sites within the collection. These components require that the scope for the feature be set to “ Site. ”
    3. Next, add a new item to the project (Right – click project name ➪ Add ➪ New Item) and select the Empty Element template from the Add New Item dialog box.
    The Empty Element template is an XML fi le where you can enter CAML Field definitions.
    Following is what you will add in your elements.xml file –
    < Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
    < Field ID="{76C140E1-D827-433B-AD38-257F9594B846}"
    Name="CustomCol"
    DisplayName="My Custom Site Column"
    Group="Custom group"
    Type="Text"
    Required="FALSE"/ >
    < Field ID="{5F516D92-969C-4661-81B9-C9210E2A2FDC}"
    Name="Choice Type"
    DisplayName="My Choice Type"
    Group="Custom group"
    Type="Choice"
    Required="FALSE" >
    < CHOICES >
    < CHOICE > Medical < /CHOICE >
    < CHOICE > Dental < /CHOICE >
    < CHOICE > Vision < /CHOICE >
    < CHOICE > Insurance < /CHOICE >
    < /CHOICES >
    < /Field >
    < /Elements >
    4. To deploy the Site Columns defined in the Elements file, right – click the project name in the Visual Studio Solution Explorer, and select Deploy. This will deploy the solution file to the solution store and activate the Feature in the targeted site collection.

  • How to programmatically create a site column and a content type

    Hello,
    I'd like to create a site column (let's say a field text) and a content type, only  using c#  -i.e. I don't want to add new item/column and then xml. This code will be added to a FeatureActivated.My code is :
    public override void FeatureActivated(SPFeatureReceiverProperties properties) {SPWeb rootweb = (SPWeb) properties.Feature.Parent;
    SPFieldText field = new SPFieldText(SPfiledscollection???, "field1");
    if (field != null)
    rootweb.Fields.Add(field)
    rootweb.Update();
    }   SPContentType newContentType = new SPContentType(spcntenttypeId??, SPContentTypeCollection ??, "content1");
       rootweb.ContentTypes.Add(newContentType);
       rootweb.Update();
    Are there any sample codes out there? I've only found samples using xml - which has an irritating "feature"
    Thank you
    Christos

    Nice code and it helped me understand. Some small questions. I'm trying to make all the "data" for a (sub)web site.
    So, I think, my steps are:
    1. create site columns+content type
    2. create  list
    3. create a lookup site column that uses the list on <2>
    4. create content type that uses the site column on <3>
    5. Create the list for the content type on <4>
    My confusion is: should I use one feature for everything? Your code is using scope=site, so i need to "hardcode" the web site's name. I don't mind doing that , I just don't know how to use scopes in features for creating data.
    Thank you
    Christos

  • PLEASE HELP!! I've used iWeb to create multiple sites, all published to third party servers.  The very last site I made changes to is showing up in any domain file I open - despite their different names and locations on my iMac.  I just switched to Lion.

    Please HELP!!  I just switched to Lion.  I have created multiple websites using iWeb  3.0.4 and despite my having saved their 'domain' files in various locations and using different filenames, upon opening the domain files I keep getting the very last site I published.  All the sites were published to third party servers.  The domain files (still have a preview that look correct and have different file sizes) but keep going back to the last site published. HELP ME PLEASE!! Are the old files still available?!!

    In Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    To open your domain file in Lion or to switch between multiple domain files Cyclosaurus has provided us with the following script that you can make into an Applescript application with Script Editor. Open Script Editor, copy and paste the script below into Script Editor's window and save as an application.
    do shell script "/usr/bin/defaults write com.apple.iWeb iWebDefaultsDocumentPath -boolean no"delay 1
    tell application "iWeb" to activate
    You can download an already compiled version with this link: iWeb Switch Domain.
    Just launch the application, find and select the domain file you want to open and it will open with iWeb. It modifies the iWeb preference file each time it's launched so one can switch between domain files.
    WARNING: iWeb Switch Domain will overwrite an existing Domain.sites2 file if you select to create a new domain in the same folder.  So rename your domain files once they've been created to something other than the default name.
    OT

  • Using iWeb to create a site uploaded to another domain via Fetch or the lik

    I'm sorry for the like subject line, but I don't know what to call what I'm looking for.
    I create my website in iWeb, publish to a folder, put it up on my personal domain using Fetch. (www.cynfrank.com) My domain is hosted by a company called Vario.
    My question is how do I add things like a feed from my LibraryThing account that features books from my library on my site? It gives me an HTML code, but I don't know where to put it in iWeb so it works. When I got this same type of code for a video I was posting in a blog entry, I simply dragged and dropped it on my iWeb page, published, put and it worked. It was like magic. Maybe I'll try it.
    Also, how do I put iTunes playlists on my site? Drag and Drop as well?
    CindyLoo

    Thanks for the quick reply. However, after I posted, I was playing around in iWed and stumbled onto the Widget and suddenly, like magic, it dawned on me what it does.
    As for the iTunes playlist....just drag and drop. It's like magic! But then isn't that the standard us MacUser have come to expect from our computers?
    Thanks again.

  • Using iWeb to create a site for another .Mac family pack user

    I started a new site in iWeb for our son today, but I can't see how to upload it so it resides in his part of the family account we have on .mac.
    Is this possible?
    If not, if I publish his pages how does it interact with our main family site that is currently uploaded.

    But with two sites in iWeb now, what will end up on my son's part of the site when I hit publish? Should I try to keep changes to just one site or the other and do the user ID switch, or will it try to post all the pages to each account?

  • Target Site Column Data Type are Undefined Status

    Hi,
    When I created the mapping,there was a error about data type. Data types of columns were not changed, and datatypes status are undefined.
    I take this error as below;
    com.sunopsis.tools.core.exception.SnpsSimpleMessageException: The source datatype is null for the column: <ColumnName>, and the technology: Hyperion Planinng
    ODI 10.1.3.5
    SQL Server 2005
    Hyperion Planning 11
    How can I changed the datatypes? Is there a problem with hyperion planning site? How can assign the data types?
    thanks.

    First of all the error you posted
    "The source datatype is null for the column: <ColumnName>, and the technology: Hyperion Planinng"
    Which points to Hyperion planning....
    Anyway, if as you say it is file to SQL Server, check the DataStore for the reversed SQL server table, check the columns have a Type assigned to them
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How do you use Class Auto Create Parameter of Web Resource Type in WPC?

    In our project, we decided to use wpc for news implementation and we need that content web be  automatically  placed on a container.
    I saw the parameter, but I didn't find more helpful information
    Regards.
    null

    Thanks so much!
    Like I said I am new to Apple products so it's still unclear to me which programs I do or don't need as I'm setting up and configuring all my software and devices.
    The Logitech Control Center appears to work perfectly for what I was trying to do!
    I accidently clicked "This helped me" instead of "This Solved My Question", sorry about that this was a solve!

  • Creating a new Column for my list Versus adding it from existing site columns, when to use each approach

    I have created a new issue tracking list inside SharePoint 2013 team site. And it comes with predefined columns, some of them are useful while the other are not . Can anyone help me in figuring out the following:-
    The list come with a field named “Assigned To”, while in my case I want a column named “Approver”. So what is preferred , to re-name the “Assumed to ”column to “Approver”, or create new field name “Approver”.?.
    If I rename an existing column, could this be overridden in any future updates for my SharePoint server?
    Now we want to add a column named “Office location”.so I need to create a new field for this. But seems there are two ways to do so either to add a new Site Column at the site level and then assign it to the list as follow :- 
    , or to directly adding a column to the list, even if it is not available in the site columns , as follow:-
    So what are the differences between the two approaches ? .if I am not wrong defining a site column will allow me to re-use it in another list , but defining the column at the list level, will allow me to add a column even if it is already defined as site
    column.
    So can anyone advice on my three questions please? Thanks

    1) 'Assigned to' has a different meaning then 'Approver' , it will be better if you create a new field for 'Approver'. Assigned to is a Site Column which has managed property for search, so it will be confusing type of data it will return from search in
    future. 
    2) Any rename of fields should not / and will not get modified in SharePoint updates. So, you can rename is without any issue since the internal name will remain the same. But its always better to create your own custom column for business use.
    3) Creating a site column or not depends upon your need, If you create a Site Column - in whole site collection you will be able to add this field in any list - It will be crawled, SharePoint will automatically provide managed property for site column and
    you will be able to get this value via search. These things will not be present in list column, you will need to do specific settings in case its required.
    If these things are needed then you can go for Site Column, usually its good to create a Site Column and use it.
    For Site Columns you can check following links 
    Introduction to Columns
    From site column to managed property - What's up with that?
    Create a site column
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.
    thanks a lot for your reply it is really helpful. so as i understand that using site columns will be better in most cases, and there is not any specific reason for not using it? is this right ?
    Second question, do u mean that if i have a list column named "Serial number", then this column will not be searched ? For example if i have serial number such as "12345" and i try searching this text "12345" i will not get
    the item in my search ?
    Thanks

  • How to set RelationshipDeleteBehavior on a list using a site column and content type programatically CSOM c#

    On Prem development machine, I'm writng a deployment routine in c# using the client object model.  I've created some site columns of type Lookup, I've created a content type and added those lookup columns to it and I've created a list using the
    content type.  I want to set the RelationshipDeleteBehavior property on some of the lookup columns in the list.  I'm also using the 16 assemblies.
    List list = cc.Web.GetListByTitle("MyList");
    cc.Load(list);
    cc.ExecuteQuery();
    Field f = list.Fields.GetByInternalNameOrTitle("MyLookupField");
    cc.Load(f);
    cc.ExecuteQuery();
    (f
    as
    FieldLookup).RelationshipDeleteBehavior =
    RelationshipDeleteBehaviorType.Restrict;
    f is returning as a Field but (f
    as
    FieldLookup) is returning null here.  Any insight on this?
    Thank you.
    Dan Budimir

    Hi,
    We can use SP.ClientContext.castTo method to convert the field to lookup field . The following code snippet for your reference:
    ClientContext context = new ClientContext("http://siteurl");
    NetworkCredential credentials = new NetworkCredential("username", "password", "domain");
    context.Credentials = credentials;
    Web web = context.Web;
    List list = web.Lists.GetByTitle("MyList");
    Field field = list.Fields.GetByInternalNameOrTitle("MyLookupField");
    FieldLookup lookupField = context.CastTo<FieldLookup>(field);
    lookupField.RelationshipDeleteBehavior = RelationshipDeleteBehaviorType.Restrict;
    lookupField.Indexed = true;
    lookupField.Update();
    context.ExecuteQuery();
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • In PWA, can I use a "Site Column" as "Custom Field" or vise versa?

    Hello,
    I am using PS 2013; I was wondering how/where "Custom Fields" are created? How there are related to the Site Column?
    Can I create a site column and use it as a Custom Field? 
    Hope my question is clear ^_^

    Hello,
    As Guillaume has mention, there is no link between SharePoint site columns and Project Server custom fields, they are different entities used for different parts of the system. Site Columns are a SharePoint setting that can be used in the lists / libraries
    on the SharePoint sites. Project Server custom fields are used by Project Server and not SharePoint. Project Server custom fields are created via the PWA > PWA Settings > Enterprise Custom Fields and Lookup Tables page. You can see a post
    here on creating Project custom fields in the second half of this post:
    http://pwmather.wordpress.com/2014/01/17/getting-started-with-projectonline-part-2-ps2013-office365-project-ppm-sharepointonline-pm/
    Scroll down to the section starting with: "Before we look at creating custom fields lets have an overview.." for details on custom fields.
    You can also create Project Server custom fields and lookup tables programmatically using the PSI / CSOM / JSOM if needed.
    There are ways in which you can "sync" SharePoint columns with Project Server custom fields but this is not out of the box. You would need to look at developing your own solution or look for a 3rd party solution. Fluent Pro have a solution to sync
    Look up tables with other sources such as a SharePoint list, see the Lookup Manager here:
    http://www.fluentpro.com/project-server/other-products/products-for-project-server-2013/
    If you just want Project Server data / fields to be available as a option for a list item on a SharePoint list, look at using the BCS, an example can be seen here:
    http://blogs.catapultsystems.com/epm/archive/2010/11/02/adding-project-server-data-as-columns-to-sharepoint-sites.aspx
    Hope that helps
    Paul
    Paul Mather | Twitter |
    http://pwmather.wordpress.com | CPS |
    MVP | Downloads

  • Create Site Column and add it to two different list as dependent lookup column

    I want to create two lookup lists that will have one common column. The common column values will vary depending on the list.
    For ex: List A holds Countries (USA) and their Currency code (USD). List B holds States (New York) and their code (NY). The lists are completely independent of each other. I would like to create a common site column named "Code" of type
    Text and use it across these two lists. Is it possible?
    My solution so far -
    a. created the site column (programmatically) which is pretty straight forward.
    b. created list definition with two fields (Title and Code).
    c. created list instance for Country list. Added data rows in the elements.xml. But not sure how to add Code field as dependent lookup.
    If I remove the code field from the elements.xml, the solution deploys successfully creating the Country list with just the Title field. But I need both the fields. Any help is appreciated.
    Here is a look at the elements.xml with data rows for Country list instance
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <ListInstance Title="List Instance" OnQuickLaunch="TRUE" TemplateType="10001" Url="Lists/CountryList" Description="Country Values">
    <Data>
    <Rows>
    <Row>
    <Field Name="Title">USA</Field>
    <Field Name="Code">USD</Field>
    </Row>
    <Row>
    <Field Name="Title">Japan</Field>
    <Field Name="Code">Yen</Field>
    </Row>
    <Row>
    <Field Name="Title">Australia</Field>
    <Field Name="Code">AUD</Field>
    </Row>
    </Rows>
    </Data>
    </ListInstance>
    </Elements>

    Hi,
    According to your post, my understanding is that you want to add lookup field to the list in elements.xml.
    I recoment you to create lookup column as site column, then bind the lookup column to the contnet type, and then use the contnet type in the list.
    For more information, you can refer to:
    http://spcodes.blogspot.com/2013/02/create-custom-content-type-with-lookup.html
    http://social.msdn.microsoft.com/Forums/office/en-US/d5ec08d5-cfa7-4bbb-9459-78d04674ee59/add-a-lookup-column-in-the-schemaxml?forum=sharepointcustomizationlegacy
    http://www.justanothertechnologyguy.com/2013/01/how-to-create-and-connect-lookup-fields.html
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Site Column created through Feature shows & in SharePoint Views

    Hi,
     I created a SharePoint Site Column using the following. The site column is provisioned correctly, added to a site content type and then to a list. Items are also created in the list. No problem. But for special characters like & the list view shows
    the value as &amp; . For example if the value for this column for an item is  Hans & Hans, in the list view it is displayed as Hans &amp; Hans. 
    Is there any other setting other than HTMLEncode="TRUE"? What am i missing here? Pls suggest
    <Field ID="{B8A32C98-166D-404C-BD10-C93C63779619}"
    Group="myWorkPlace"
    Name="MWPfld_CompanyName"
    DisplayName="Company Name"
    Type="Text"
    Required="TRUE"
    Indexed="TRUE"
    ShowInDisplayForm="TRUE"
    ShowInEditForm="TRUE"
    ShowInNewForm="TRUE"
    HTMLEncode="TRUE"
    >
    </Field>
    Thank you all.

    Hi,
    Thanks for your sharing, it will be beneficial to those who stuck with the similar issue.
    Best regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Is there a way to know if my Content Type's fields are a Site columns or List columns

    I am totally confused about Site columns, list columns and content types. as seems i will have the same column name , sometimes dealt with as site column while the other as list column. for example i created a new Issue tracking list which comes with the
    following columns:-
    now i realize that the Description column is a list column (not site column) because if i rename the site column named Description, this list column will not get affected, while column such as "Issue status" is a site column because if i rename
    the site column named "Issue Status" the column inside the "Issue" content type will get affected. while there are two site columns named Description but none of them are used insidie the "Issue" content type, and the Description
    field in the above picture is a list column !!
    so can anyone advice from where i can differentiate if a column inside the Issue content type is a site column or is a list column ???
    Thanks

    Hi John,
    Thanks for posting your issue, Kindly browse the below mentioned URL to identify the site columns and Content Type in your Top level site
    http://www.kalliance.com/blog/tips-tutorials/microsoft/identifying-site-columns-content-types/
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • Add site column with ID via Powershell

    Hi,
    Could somebody please help me with this. I want to create a site column using PS script where i can give the display name, internal name, Field ID etc.
    Giving Field ID is important for me. Thanks.
    -Prashant

    Hi,
    It seems like I was writing the correct script but I think i have some different problem.
    Scenario:
    In my old SP2010 environment, one list template was created using feature (via declarative XML). This list template has two custom columns which were also created via feature. Now in so many site collections users have used that list template to create the
    list instances.
    In SP2013 environment, I do not have these features installed in the farm and without these customizations installed in SP2013 environment I have upgraded some sites. Now all those list instances which were created using custom list template type are not
    opening at all since the feature which was used for creating the list template is missing in this new SP 2013 environment.
    So is there any way to fix this problem without installing the features in new environment? I thought if i will add those two site columns again via PS script, it may work but i think its failing because of whole list schema.
    -Prashant

Maybe you are looking for

  • HELP!!! Could someone help me with a jar file issue and JRE 1.3 and JRE 1.4

    We had a problem with the last Oracle patch in that it tried to extract from a jar file using the "jar" executable. But the jar executable is not installed on the server where we have JRE 1.4 On one server, Jar.exe is installed where we have JRE 1.3.

  • ITunes Sync Problems With iPhone & iPod Apps

    Since i upgraded my Mbp i started getting this strange problems, its effecting both iPhones and iPod, I got a new model MBP so copy my entire itunes collection and sync it with the new mbp, also copied over the iphone and ipod data (backups) now ever

  • I am unable to uninstall the trial of Photoshop Elements 8

    So I downloaded the trial version of  Adobe Photoshop Elements 8 because I needed to work on a project and at  the time I didn't have enough money to buy the full software. One day my  paintbrushes screwed up (all of them have a large amount of spaci

  • Switching from ODP 9.x to ODP 10 and ODT

    We currently are using ODP 9 with VS 2003 and Oracle 9i databases. However, I would like to switch over to the new Oracle Developer Tools and ODP 10. From what I have seen, I believe this works fine with our Oralce 9i databases. However I am confused

  • Best practice for @EJB injection in junit test (out-of-container) ?

    Hi all, I'd like to run a JUnit test for a Stateless bean A which has another bean B injected via the @EJB annotation. Both beans are pure EJB 3 POJOs. The JUnit test should run out-of-container and is not meant to be an EJB client, either. What is t