Copied to clipboard

Flag this post as spam?

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


  • Ben Norman 167 posts 276 karma points
    Nov 20, 2013 @ 21:31
    Ben Norman
    0

    v6 API - IContentService.SaveAndPublish and "Picker Relations"

    I am trying to maintain relations using a multi node tree picker, picker relations and a uComponents: Relation Links.

    When I use the backoffice to change the values stored by the multi node tree picker using the v6 API, the relations are added and removed as expected but when I use the v6 API, in particular, item.SetValue("MNTPProperty", {1,2,3,4}), the list of relations is not affected when I do a Save and Publish.

    How do I get the picker relations to fire?

  • Ben Norman 167 posts 276 karma points
    Nov 20, 2013 @ 21:53
    Ben Norman
    0

    I can create the relations using the backoffice. A comment is created which looks like the following: ["PropertyTypeId":133].

    When I use the v6 API, to be able to set up the relations so that I can edit them using the backoffice, I have to set the comment in the backend so that it will match the comment generated by the backoffice. If I don't do this, the relation will not be affected by changes made in the backoffice.

    var instanceIdentifier = "[\"PropertyTypeId\":133]";
    // For each PickerRelations datatype
    //foreach (Property pickerRelationsProperty in from property in newSite.PropertyTypes
    //                                             where property. == pickerRelationsId
    //                                             select property)
    //{
    //    // used to identify this datatype instance - relations created are marked with this in the comment field
    //    instanceIdentifier = "[\"PropertyTypeId\":" + pickerRelationsProperty.PropertyType.Id.ToString() + "]";
    //}
    var relationType = rs.GetRelationTypeByAlias(RelationTypes.MemberWebsite.ToString());
    var relation = new Relation(newSite.Id, owner.Id, relationType);
    //umbraco.cms.businesslogic.relation.Relation.MakeNew()
    relation.Comment = instanceIdentifier;
    rs.Save(relation);
    

    How can I generate the instanceIdentifier?

Please Sign in or register to post replies

Write your reply to:

Draft