How to Create Custom Content Type with 100 site columns ?

Hi EveryOne,
i have one requirement to create custom conten types in sharepoint 2013 as follows.
1. Create a content type with 100 site columns ( in this 100 site columns includes 10 mms feilds and 10 lookup fields).
2.when we deploy the content type in other server if already the same content type existing in the server it should be upgrade the existing content type.
Please advise how do develop the solution ( using power shell script or visual studio with event receiver or xml file)
Regards,
Srinivas

Try below:
http://www.mindfiresolutions.com/Add-Columns--Fields-Programmatically-to-a-SharePoint-List-282.php
using(SPSite
oSPsite = new SPSite("http://Web-URL"))
    oSPsite.AllowUnsafeUpdates =
true;
using (SPWeb oSPWeb = oSPsite.OpenWeb())
        oSPWeb.AllowUnsafeUpdates =
true;
/* get the SPList object by list name*/
SPList lst = oSPWeb.Lists["EmpList"];
/* create a Numeric field for EmpID */
SPFieldNumber fldEmpID = (SPFieldNumber)lst.Fields.CreateNewField(
SPFieldType.Number.ToString(),
"EmpID");
        fldEmpID.Required =
true;
        fldEmpID.DisplayFormat =
SPNumberFormatTypes.NoDecimal;
/* create a Text field for Name */
        SPFieldText fldName = (SPFieldText)lst.Fields.CreateNewField(
SPFieldType.Text.ToString(),
"Name");
        fldName.Required =
true;
        fldName.MaxLength = 50;
/* create a Date field for Dob*/
SPFieldDateTime fldDob = (SPFieldDateTime)lst.Fields.CreateNewField(
SPFieldType.DateTime.ToString(),
"Dob");
        fldDob.DisplayFormat =
SPDateTimeFieldFormatType.DateOnly;
/* create a Currency field for Salary */
        SPFieldCurrency fldSal = (SPFieldCurrency)lst.Fields.CreateNewField(
SPFieldType.Currency.ToString(),
"Salary");
        fldSal.Currency =
SPCurrencyFieldFormats.UnitedStates;
        fldSal.DisplayFormat =
SPNumberFormatTypes.TwoDecimals;
/* add the new fields to the list */
        lst.Fields.Add(fldEmpID);
        lst.Fields.Add(fldName);
        lst.Fields.Add(fldDob);
        lst.Fields.Add(fldSal);
/* finally update list */
        lst.Update();
        oSPWeb.AllowUnsafeUpdates =
false;
    oSPsite.AllowUnsafeUpdates =
false;
If this helped you resolve your issue, please mark it Answered

Similar Messages

  • Creating Custom Content Types

    As the title suggests,  does anyone know how to create Custom Content Types in Adobe Livecycle Content Services ES?  I have looked far and wide across the www, and haven't had any luck with a straight forward, easy to follow, tutorial on the subject.  I have seen it for Actions and Aspects, but not Content.
    Thank you in advance,
    Alex

    Marc,
    Thanks for your response.  I've spent the past couple of days trying to get it to work, but I still cannot figure it out.
    According to all documentation I have found, I have modified the files I thought were the same as the Alfresco files:
    C:\...\jboss\server\all\deploy\contentservices.war\WEB-INF\classes\alfresco\extension
                   + .\liveCycleContentModel.xml
                        Added the <types> tag above the <aspects> tag, and created my type as specified online and also in a book
    Then I copied the web-client-config.xml to the extension folder and renamed as web-client-config-custom.xml and added the code to Content Wizards and Action Wizards to display it in the web ui.
    Am I missing anything?  When I re-package the .war file and redeploy/restart JBOSS, my localhost:8080/contentspace is completely broken.  no login in or anything but workspace is still in tact.
    Thanks for any further help,
    Alex

  • SharePoint 2013 Custom Content Type with Site Column custom validations

    Hello,
    Can somebody please suggest me how I can create custom content type with site columns with custom validation to site columns programmatically?
    Thanks,
    Praveen Kumar Padmakaran

    Hi,
    From your description, my understanding is that you want to create content type with site column with validation.
    You could create a site column, and add some validation to the site column. After you could create a custom content type, please add the site column with validation to the content type. Please refer
    to this code below:
    static void Main(string[] args)
    // replace your url
    using (SPSite site = new SPSite("http://sp/sites/sp2013"))
    using (SPWeb web = site.OpenWeb())
    //define the type of the field
    SPFieldType type = SPFieldType.Number;
    // create a site column
    SPField field = CreateSiteColumn(web, "newTest", type, "");
    // add custom formula for the field
    SPFieldNumber fieldNumber = web.Fields.GetField("newTest") as SPFieldNumber;
    fieldNumber.ValidationFormula = "=[newTest]>5";
    fieldNumber.ValidationMessage = ">5";
    fieldNumber.Update();
    SPContentTypeId parentItemCTypeId = web.ContentTypes[0].Id;
    // create custom content type
    SPContentType contentType = CreateSiteContentType(web, "newContent", parentItemCTypeId, "Custom Content Types");
    // add the site column to the content type
    AddFieldToContentType(web, contentType, field);
    // add fiedl to contenttype
    public static void AddFieldToContentType(SPWeb web, SPContentType contentType, SPField field)
    if (contentType == null) return;
    if (contentType.Fields.ContainsField(field.Title)) return;
    SPFieldLink fieldLink = new SPFieldLink(field);
    contentType.FieldLinks.Add(fieldLink);
    contentType.Update();
    // create a custom content type
    public static SPContentType CreateSiteContentType(SPWeb web, string contentTypeName,SPContentTypeId parentItemCTypeId, string group)
    if (web.AvailableContentTypes[contentTypeName] == null)
    SPContentType itemCType = web.AvailableContentTypes[parentItemCTypeId];
    SPContentType contentType =
    new SPContentType(itemCType, web.ContentTypes, contentTypeName) { Group = @group };
    web.ContentTypes.Add(contentType);
    contentType.Update();
    return contentType;
    return web.ContentTypes[contentTypeName];
    // create a site column
    public static SPField CreateSiteColumn(SPWeb web, string displayName,SPFieldType fieldType, string groupDescriptor)
    if (!web.Fields.ContainsField(displayName))
    string fieldName = web.Fields.Add(displayName, fieldType, false);
    SPField field = web.Fields.GetFieldByInternalName(fieldName);
    field.Group = groupDescriptor;
    field.Update();
    return field;
    return web.Fields[displayName];
    You could refer to these articles:
    C# code to create Site Column, Content Type, and add fields to Content Type
    http://spshare.blogspot.jp/2013/10/c-code-to-create-site-column-content.html
    How to do custom validation for site column in SharePoint
    http://www.c-sharpcorner.com/uploadfile/anavijai/how-to-do-custom-validation-for-site-column-in-sharepoint/
    Best Regards,
    Vincent Han
    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].

  • I lost the ability to order and hide site columns if i use custom content type with a custom Create Form

    I have a team site collection and I want to add a new App of type Issue Tracking list. so I did the following:-
    From the site collection I created a new App of type issue tracking.
    Then from the site collection I created a new Content type named “CustomIssue” which has its parent as “Issue” content type.
    I went to the Issue tracking list and I changed the default content type from Issue , to the new “CustomeIssue” content type.
    I open the site collection using SP designer and I created a new Create form for my Issue tracking list based on the "CustomIssue" content type and I select to have the Create form as the default form when creating an item.
    Everything till this point worked well. But when I open the “customIssue” content type , and I re-order the columns and I hide some columns, this was not reflected inside the custom Create form …
    although when using the default content type and the default create form you can control the order of the fields and to specify if certain fields hold be hidden inside the Create form.. so can anyone advice on this please?

    Hi,
    According to your post, my understanding is that you lost the ability to order and hide site columns if i use custom content type with a custom Create Form.
    I try to reproduce the issue, the result is the same as yours.
    As a workaround, if I modify the custom content type form the site setting, and then change the NewForm as the default form, it will change the column orders.
    However, if I use the new created form as the default form, it will remain the original orders.
    I recommend that you modify the custom content type form the site setting, and then reset the NewForm as the default form.
    The result is as below:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support
    ok thanks for the explanation ,, but what if i want to change the order and hidde some fields in the future ,, do i have to chnage the defualt create form again ...

  • How to create custom content placeholder in sharepoint 2013

    Hi, I would like to create custom content placeholder don't know how to and add to my custom master page in sharepoint 2013. I have no luck searching on how to create custom content placeholder, any help?
    Thanks,
    Johnweb

    Hi,
    If you’re not fixed your requirement with the Out of the box SharePoint place holders, you can create as many as you want as long as the ID doesn’t conflict. On the master page add the content place holder 
    <asp:ContentPlaceHolderid="CustomName" runat="server"></asp:ContentPlaceHolder> and add this to your page layout
    <asp:Contentrunat="server" ContentPlaceHolderID="CustomName"></asp:Content>.
    I suggest you provide your basic requirement for further research.
    If you want to customize a master page, the Rajendra's method would be helpful.
    Best Regards,
    Dennis Guo
    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]

  • How to create external content type in sharepoint for salesforce account

    Can anybody help me on How to create external content type in sharepoint for salesforce account.
    I wanto upload documents to a document library which should sync with accounts in saleforce.
    thanks in advance

    Hi,
    The following materials would be helpful:
    Tutorial: Access Salesforce Leads in SharePoint through an External List
    http://geekswithblogs.net/dataintegration/archive/2014/02/03/tutorial-access-salesforce-leads-in-sharepoint-through-an-external-list.aspx
    Salesforce SharePoint Integration – Best Practices
    http://rainforce.walkme.com/salesforce-sharepoint-integration-best-practices/#.VFxra3mKAeE
    If you want to upload documents to SharePoint document library from the Saleforce, we can also customize your own web service using SharePont .Net Client Object Model or REST to achieve it.
    Best Regards 
    Dennis Guo
    TechNet Community Support

  • How to create attribute & set types with customer namespace COMM_ATTRSET?

    Hi CRM Gurus,
    I want to create some attributes and set types on CRM system with
    `/FITGL/` namespace but system is not allowed to create objects
    according. After debugging derives that SAP standart coding given below
    on LCOM_ATTRIBUTE_NEWF19 include.
    IF ( lv_systemname <> gc_sap_system ) AND
           ( iv_object_name(1) <> 'Y' AND iv_object_name(1) <> 'Z' ).
    Should we make an enhancement on this include? Is there any side
    efffects of this enhancement creating attribute & set types on CRM
    system during the packaging in terms of related with other attribute & set types objects?
    Kind Regards,
    Fahrettin

    Hi CRM Gurus,
    I want to create some attributes and set types on CRM system with
    `/FITGL/` namespace but system is not allowed to create objects
    according. After debugging derives that SAP standart coding given below
    on LCOM_ATTRIBUTE_NEWF19 include.
    IF ( lv_systemname <> gc_sap_system ) AND
           ( iv_object_name(1) <> 'Y' AND iv_object_name(1) <> 'Z' ).
    Should we make an enhancement on this include? Is there any side
    efffects of this enhancement creating attribute & set types on CRM
    system during the packaging in terms of related with other attribute & set types objects?
    Kind Regards,
    Fahrettin

  • How to get Custom-Content-type Column Value of a Document Library-Folder

    Hello
    I have to add a custom-column(folder-imageURL) for Folders in a Document Library.
    So I have created a Custom-CotentType "FolderCtype" with new column "folder-imageURL" and attached in the Document Library.
    Whenever I create a new folder in that document library I will select my "FolderCtype" & and then add an image url in "folder-imageURL" column.
    How do I access this image url in Code?
    part of my code is as follows.
    SPContentType cntType = List.ContentTypes["FolderCtype"];
    SPField field = cntType.Fields.GetField("folder-imageURL");  //I have Field name here//
     foreach (SPFolder folder in RtFolder.SubFolders)
                        if (folder.Name.ToUpper() != "FORMS")
                           string FolderName = folder.Name;
                          string FolderImageUrl = ?              //How can I get this????//
    Thanks in advance

    Hi, Patrickm, Thank You
    If your “folder-imageURL” column is a “Hyperlink or Picture” column, then you can get the hyperlink like this:
    SPListItem item = folder.Item;
    if (item[field.Title] != null)
    string FolderImageUrl = item[field.Title].ToString().Split(',')[0];
    Console.WriteLine(FolderImageUrl);
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support
    S H A J A N

  • How to create Custom LabVIEW Node with Dynamic Pins?

    I am trying to create a new set of LabVIEW nodes that will communicate with a new protocol.
    If it's at all possible, I'd like to make the new nodes similar to other connnectivity nodes (i.e. ActiveX, .NET, etc...). There would be an Open Reference node that pops up a custom dialog when created, a Close Reference node, a Property node that dynamically changes when the reference pin changes, and an Invoke node that dynamically changes when the reference pin changes.
    Is it possible to create such nodes as sub-VI's? If so, then how? If not, then what is the prefered method of doing this?
    Thanks in advance for any help
    VRMan

    The technique to do exactly this is called XNode. It's very difficult, not
    supported or documented, and although they work in >7.1, you have to use
    scripting a lot, and that is not supported in 8.x. The technique used in 7.1
    is also preceded. I would really not recommend it. Search LAVA if you need
    to know more.
    You could do this with XControls. These technique might not do 100% what you
    want, but at least they are supported. Haven't used LabVOOP (search class or
    classes in the LV help, there are instruction tutorials and videos), but I
    think you can't make property nodes and methods. I'm sure XControls can do
    that. Both are advanced stuff...
    A third option is to make an express VI, that is configurable by double
    clicking on it. Don't like to use them myself, and therefore haven't make
    any. I think you need a toolkit to make them.
    Regards,
    Wiebe.

  • How to create a concatenated index with a long column (Urgent!!)

    We have a situation where we need to create a concatenated unique
    index with one of the columns as a "long" datatype. Oracle does
    not allow a lot of things with long columns.
    Does anyone know if this is possible or if there is a way to get
    around it.
    All help is appreciated!!!!

    From the Oracle SQL Reference ...
    "You cannot create an index on columns or attributes whose
    type is user-defined, LONG, LONG RAW, LOB, or REF,
    except that Oracle supports an index on REF type columns
    or attributes that have been defined with a SCOPE clause."
    Doesn't mention CLOB or BLOB types, so perhaps you
    should consider using one of those types instead. I have a
    feeling that the LONG type is now deprecated.

  • R12: How to create Customer contact at party/account-site level

    Hello,
    I am working on a customer conversion where the legacy system stores customer contact at the address id (i.e. party site) level.
    Using various HZ APIs I have been able to create a party, customer account, location, party site, account site and account site use.
    Now, I want to create contacts at the party site or account site level. Which API is used to create a contact? (I found a note 985500.1 but it shows creation of contact point such as a phone number or email but not the contact itself).
    Any pointers appreciated.
    Manish

    HZ_PARTY_CONTACT_V2PUB

  • How to add a default value in a site column for every item in a document library

    HI
    i created a content type with some site columns ,
    and included in a Document library.
    Process ( content type)
    -ProcessNo
    -ProcessName
    after that i uploaded 100 Documents but not  added value in a site column process name.
    now  how i add a default value in a site column for every document in a document library 
    adil

    HI
    i get below error when i change the script 
    PS C:\scripts> C:\Scripts\updatedefaultvalue.ps1
    Cannot index into a null array.
    At C:\Scripts\updatedefaultvalue.ps1:8 char:7
    + IF($i[ <<<< "Title"] -eq $null)
        + CategoryInfo          : InvalidOperation: (Title:String) [], RuntimeExce
       ption
        + FullyQualifiedErrorId : NullArray
    $web = Get-SPWeb http://tspmcwfe:89/
    $list = $web.Lists["test"]
    $item = $list.Items | Where { $_["Name"] -eq "Emc" }
    foreach($i in $items)
    IF($i["Title"] -eq $null)
             $i["Title"] = "test"
           $i.Update()
    adil
    Why are you piping a where in the items? Do you only want to add the "test" to ones matching
    a name?
    If you have ISE installed on your server I recommend you put your code in there and debug it. 
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

  • How to use custom aspx page as template for custom content type

    Hi,
    I have created custom content type and custom aspx page. I want to use aspx page as template for custom content type.
    Can anybody please let me know how to accomplish this?
    Any help would be appreciated.
    Thank you,
    AA.

    Check if you are looking for the below
    http://www.sharepointpals.com/post/How-to-Create-a-Page-Layout-(PageLayout)-with-ContentType-in-SharePoint-2013
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Can I add Custom Content Type created programmatically to Custom List Definition?

    I have created Custom content type programmatically in the Feature Receiver. Followed by this have another feature which creates List Template. I want to add the custom content type to the list template.
    Using VS 2012, I added the custom content type to the list definition. The Schema.xml for the list definition looks as below:
    <ContentTypes>
    <ContentTypeRef ID="0x010100D7D9F4B1F4A9684BB44389571024B2EC00C393BB21B8AD7B41B62A87DF0501504D" />
    </ContentTypes>
    ID was automatically added by the VS tool.
    List Template is created, the new content Type is also added, but the Name is displayed as "Document" instead of the custom content type name. So I see two CTs with the name "Document".
    How can I achieve this? Any help is appreciated.

    Hi,
    Please add EnableContentTypes="TRUE" in the <List > tag.
    The following materials would be helpful:
    How to add custom content type to a custom list
    http://innersharepoint.blogspot.de/2009/10/how-to-add-custom-content-type-to.html
    SharePoint Custom List Definition with Content Type
    https://achrafsp.wordpress.com/2013/03/31/sharepoint-list-definition-with-content-type/
    Create a Custom SharePoint List Definition
    http://www.mssharepointtips.com/tip.asp?id=1188
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Create customer master record with reference to existing division

    how to create customer master record with reference to existing division?

    what type of reports sd consultant configure in implementation project?and in supporting project?

Maybe you are looking for