Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mitton 22 posts 71 karma points c-trib
    Oct 02, 2015 @ 07:22
    Mitton
    0

    Adding a property to a document type using ContentTypeService

    I'm developing a package that will depend on a specific property on the Home document type. (Assuming a document type with alias "home" exists).

    So in ApplicationStarted, I have the following code to add the property:

    var cs = applicationContext.Services.ContentTypeService;
    var homeType= cs.GetContentType("home");
    var customerContact = new PropertyType("textbox", DataTypeDatabaseType.Nvarchar, "TestAddProp");
    homeType.AddPropertyType(customerContact);
    cs.Save(homeType);
    

    On that last line I get a SQL exception complaining that there is no primary key to use as a foreign key.

    Do I need to somehow save the the new property type first?

Please Sign in or register to post replies

Write your reply to:

Draft