Copied to clipboard

Flag this post as spam?

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


  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Feb 10, 2014 @ 19:42
    Jason Prothero
    0

    Error when more than one picker on a Document Type

    I have a document type with more than one relation that I would like to pick with the uRelate MNTP data type.  This generally seems to work as the pickers display properly on the load of the Content Page.  However, on Save or Save & Publish I get the following error:

    https://www.dropbox.com/s/1c2s3t0o1fy91jm/Screenshot%202014-02-10%2010.39.01.png

    ============================================

    Server Error in '/' Application.

     

    An item with the same key has already been added.

     

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

     

    Exception Details: System.ArgumentException: An item with the same key has already been added.

     

    Source Error: 

     

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

     

    Stack Trace: 

     

     

    [ArgumentException: An item with the same key has already been added.]

       System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +14175344

       uRelate.RelationsMultiTreePicker.MultiPickerRelationsEventHandler.GetRelationsMappings() in e:\Sites\Umbraco Local Clean\uRelate\RelationsMultiTreePicker\RelationsEventHandler.cs:408

       uRelate.RelationsMultiTreePicker.MultiPickerRelationsEventHandler.GetOpposingNodeRelationTypeId(Int32 currentNodeId) in e:\Sites\Umbraco Local Clean\uRelate\RelationsMultiTreePicker\RelationsEventHandler.cs:341

       uRelate.RelationsMultiTreePicker.MultiPickerRelationsEventHandler.DeleteRelations(RelationType relationType, Int32 contentNodeId, Boolean reverseIndexing) in e:\Sites\Umbraco Local Clean\uRelate\RelationsMultiTreePicker\RelationsEventHandler.cs:241

       uRelate.RelationsMultiTreePicker.MultiPickerRelationsEventHandler.AfterSave(Content sender, SaveEventArgs e) in e:\Sites\Umbraco Local Clean\uRelate\RelationsMultiTreePicker\RelationsEventHandler.cs:93

       umbraco.cms.businesslogic.web.SaveEventHandler.Invoke(Document sender, SaveEventArgs e) +0

       umbraco.cms.businesslogic.web.Document.Save() +325

       umbraco.cms.presentation.editContent.Save(Object sender, EventArgs e) +1644

       umbraco.controls.ContentControl.SaveClick(Object sender, ImageClickEventArgs e) +469

       umbraco.controls.ContentControl.SavePublish(Object sender, ImageClickEventArgs e) +24

       System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +134

       System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +204

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804

     

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18055

     

    ==========================

     

    Any ideas on a fix?  Is the key in the config file the nodeTypeAlias attribute or the combination of both attributes?

     

    Thanks,
    Jason

  • Neil Tootell 73 posts 118 karma points
    Feb 11, 2014 @ 11:22
    Neil Tootell
    0

    Hi Jason,

    For each r-MNTP it can only be tied to one relation set. So whilst having multiple r-MNTP's for different types of relations is fine - you need to make sure that for any one document type each r-MNTP has it's own relation set.

    It looks to me like more than one r-MNTP is referencing the same relation set.

     

    Make sense? Let me know if it's not that and I'll look again.

     

    Regards

    Neil

  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Feb 11, 2014 @ 18:03
    Jason Prothero
    0

    Neil,

    Here is my uRelate config (below).  So are you saying its the two doc2author relation types that are the problem?

    <Relations>
     <rel nodeTypeAlias="AppOverviewDoc" relationTypeAliasToUpdate="doc2author" />
     <rel nodeTypeAlias="SubTopicDoc" relationTypeAliasToUpdate="doc2author" />
     <rel nodeTypeAlias="SubTopicDoc" relationTypeAliasToUpdate="topic2topic" />
    </Relations>

     

    Perhaps I'm not understanding how it works completely...

    Thanks,
    Jason 

  • Neil Tootell 73 posts 118 karma points
    Feb 11, 2014 @ 21:25
    Neil Tootell
    0

    I think that may be the case. If both doc2author aliases are on the same document type - when you save and publish I think that's where you're getting the key conflict.

    Try as an experiment removing one of them and save&pub - see if that helps.

    Neil

  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Feb 11, 2014 @ 23:40
    Jason Prothero
    0

    I commented out the "AppOverviewDoc" line because they both use the same "doc2author" relation and it still gave the error.

    If I uncomment that, then comment out the second "SubTopicDoc" line for the relation "topic2topic" then the error goes away. The picker is still there and it saves the relation, but it puts all the topics in the author relation.  So both pickers are using the same relation.  

    It seems like that suggests that the nodeTypeAlias is the key that its throwing the error for.

    Is it possible to change the config/data type so multiple pickers can be on a doc type with different relations?

     

    Thanks,
    Jason 

  • Neil Tootell 73 posts 118 karma points
    Feb 12, 2014 @ 21:49
    Neil Tootell
    0

    Hi Jason,

    The view was to remove the reliance on the config file in a newer version of the package - but with the introduction of v7 I'm thinking of a whole new model instead.

    I'm a bit stuck without seeing your solution - could you send me a couple of screen shots of your document types for AppOverview & SubTopic?

    You can run multiple pickers on the same Doctype with different relation sets - I have a master doctype that has five rMNTP's connected to 5 different relation types. 

    My structure is...

    Master Doctype with 5 rMNTP's
    -- Sub doctype 1
    -- Sub doctype 2
    -- etc 

    I'm sorry for the late reply, I can only look at this in the evenings.

    n

  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Feb 21, 2014 @ 14:54
    Jason Prothero
    0

    Neil,

    Thanks for your responses so far.  I think if you have something working then perhaps we can get it worked out.  Perhaps we could do a Skype call and screen share so I can show you what I'm experiencing?  Can you post your uRelate.config file for the multiple rMNTPs on a DocType?

    From my end, here's some more info:

    * This is a snippet of the DocType for the SubTopicDoc that I would like to have more than one rMNTP on: https://www.dropbox.com/s/fuuudzhtalk4k3n/Screenshot%202014-02-21%2005.47.51.png

    Basically, I'd like to have a relation to authors as well as other topics.

    One thing I did find in the source is that the GetRelationsMapping() static method on the MultiPickerRelationsEventHandler is filling a Dictionary with the config values using hte nodeTypeAlias as the Key:

     

    dRelationsKeys.Add(relationMapping.Attributes["nodeTypeAlias"].Value.Trim(), relationMapping.Attributes["relationTypeAliasToUpdate"].Value.Trim());

    I believe this is why I'm having an issue.  If I have the same nodeTypeAlias in the config for more than one entry, this will throw an error or simply just miss the second config, correct?  Is there a possibility of adding the property alias in there and then using that in combination with the nodeTypeAlias to get a key that will allow more than one rMNTP on a Document Type?

     

    Thanks,
    Jason 

  • Neil Tootell 73 posts 118 karma points
    Feb 24, 2014 @ 22:01
    Neil Tootell
    0

    Hi Jason,

    Here's the config section from my site - the attribute names have changed a little as uRelate evolved...

    <Relations>
    <relnodeType="ListedBlog" aliasToUpdate="relatedBlogs" />
    <relnodeType="ListedCaseStudy" aliasToUpdate="relatedCaseStudies" />
    <relnodeType="ListedCommitment" aliasToUpdate="relatedCommitments" />
    <relnodeType="ListedEvent" aliasToUpdate="relatedEvents" />
    <relnodeType="ListedExpert" aliasToUpdate="relatedExperts" />
    <relnodeType="ListedManagementProfile" aliasToUpdate="relatedManagementProfiles" />
    <relnodeType="ListedPressRelease" aliasToUpdate="relatedPressReleases" />
    <relnodeType="ListedValue" aliasToUpdate="relatedValues" />
      <relnodeType="ListedResonsibility" aliasToUpdate="relatedResonsibility" />
    </Relations>

     

    I have a document type that all my listed document types inherit from, and the MNTP's are all on that document type.

    I can't do a skype at present. Would you be able to send me a backup of your site and I'll have a look?? - I'm hoping it's just a configuration issue as it seems what you're trying to do is easily achievable using the package.

    It should be as long as Authors & Related Topics both connect to a distinct relation type you should be fine. Having more than one rMNTP on a single document type is standard practice - so I think it may be something else. Have you set your rMNTP to csv?

     

    Regards

    Neil

     


  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Mar 05, 2014 @ 05:01
    Jason Prothero
    0

    Neil,

    Is there a newer version that we should be using?  Or perhaps I could just do a quick compare of the code I have versus a newer version?  Could be that you fixed something in a later version that helps.

    I am using CSV and each type has its own Data Type (Author rMNTP and Topic rMNTP) that only allows specific DocTypes to be selected.

    I don't think I can share the whole project unfortunately.  I'll look into if I have enough time to create a clean install and see if I can get that to break.  In the mean time if there is any updated code you can send, or any other ideas please let me know.

     

    Thanks,
    Jason 

  • Anthony 11 posts 52 karma points
    Sep 02, 2014 @ 12:10
    Anthony
    0

    Hi Jason or Neil,

    I find myself in the exact position that Jason was speaking about. My document type/relation structure is as follows:

    EntityA relates to EntityB

    AND 

    EntityA relates to EntityC

    so in my uRelate.config file, I have to have the entries as follows:

    <Relations>
        <!-- Entity A -> Entity C -->
        <rel nodeTypeAlias="EntityA" relationTypeAliasToUpdate="relateEntityA-And-EntityB" />
        <rel nodeTypeAlias="EntityB" relationTypeAliasToUpdate="relateEntityA-And-EntityB" />
    
        <!-- Entity B -> Entity C -->
        <rel nodeTypeAlias="EntityA" relationTypeAliasToUpdate="relateEntityA-And-EntityC" />
        <rel nodeTypeAlias="EntityC" relationTypeAliasToUpdate="relateEntityA-And-EntityC" />
    </Relations>

    This causes the error Jason describes above "An item with the same key has already been added." because there are duplicate keys (nodeTypeAlias) in the uRelate.config file.

    My questions are as follows

    • How do we set up a document type with multiple uRelate MNTP relationships?
    • OR Should we only use uRelate at the Child part of the Relation to get it to work?
    (Forgot to mention Umbraco version 4.11.10 - I cannot upgrade at this stage)
Please Sign in or register to post replies

Write your reply to:

Draft