Copied to clipboard

Flag this post as spam?

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


  • Zihadul Azam 26 posts 171 karma points c-trib
    Dec 11, 2017 @ 09:42
    Zihadul Azam
    0

    Create a new RelationType

    How can I create a new Relation Type with Umbraco Relation Service? At application started I want to define all my Relation Types (which I'm going to use in my application later). Is it possible?

    -thanks

  • Matt Darby 28 posts 391 karma points c-trib
    Dec 11, 2017 @ 11:47
    Matt Darby
    101

    Hi,

    It is possible - for example:

        var relationType = new RelationType(new Guid("A7CE7344-9A2E-4567-8BC9-8901BB9B9F5B"),new Guid("F65E0D53-E0A9-46D9-94D7-EA5009E48D55"), "relationTypeAlias", "Relation Type Name"){IsBidirectional = true};
        ApplicationContext.Services.RelationService.Save(relationType);
    

    Check out how Umbraco does it here:

    https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/umbraco.presentation/umbraco/developer/RelationTypes/NewRelationType.aspx.cs#L53

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies