locked
cant delete mappings of 1:n connection RRS feed

  • Question

  • Hi all, 

    is this normal, or is there an error on our crm server?

    I have a 1:n connection from contact to an custom entity.

    if i go to mappings of this connection i see that by standard all other 1:n connections (only from contact to the same custom entity) have an mapping entry like this:

    sourcename   / destinationname

    contactid ... Contact / new_example1id ... Example 1
    contactid ... Contact / new_example2id ... Example 2

    I only wanted to map 1 of these lookups, not all, because the problem ist .. that if i create a new custom entity entry from out of my contact, all these contact-fileds will be filled automatically with the contact entry, from which i started the creation of the new custom entity entry. But this is wrong.

    Can anyone test this, if this is wrong by design?

    MANY MANY THX to all..

    Greetings, Pit

    Friday, March 1, 2013 2:22 PM

Answers

  • In your case where you have the same relationship defined twice - you won't be able to delete the default mapping that is generated by the system.

    What you could do - to the field you don't want to map over when creating from the Contact is add some JavaScript non the form OnLoad event when the record is first created to remove the value if present.

    function OnLoad() {
        if (Xrm.Page.ui.getFormType() == 1) {
            if (Xrm.Page.getAttribute("new_exampleid2").getValue() != null) {
                Xrm.Page.getAttribute("new_exampleid2").setValue(null);
            }
        }
    }


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Tuesday, March 5, 2013 4:29 AM
    Moderator
  • Because you have multiple lookups to the same entity, it means the mappings are the same. This is because the mappings for a relationship apply to all relationships between these 2 entities, I believe this has to do with the way CRM opens records from the context of another, as it does not know which grid/relationship you create the child record from, it only knows the ID of the parent created from.

    In other words, you cannot have 2 relationships from the same entity to the same entity with different mappings. Also, as you have witnessed, the lookup fields on the child record to the parent entity will automatically be added to the mappings, and these cannot be removed.

    The only way to remove the second value is by using JavaScript like Jason has mentioned, however this only works well for one of the relationships.

    Paul

    • Marked as answer by Pe.B Tuesday, March 5, 2013 8:14 AM
    Tuesday, March 5, 2013 5:52 AM

All replies

  • does anyone have the same problem ....

    or can you delete all mappings of the lookups?

    Please help. it is really important for me to know, if we have a problem or if ms has done this by design.

    THX, greets pit

    Monday, March 4, 2013 9:34 AM
  • If i want to delete the other not necessary mappings, i geht the following error and cant delete it .. and this is the problem. I need to delete this?

    I want to know if this is planed from ms, to can not delete this, or if this is an issue with our config / server?!

    Cannot create or delete a system AttributeMap.

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #C74E3128Detail: 

    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220970</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
      <Message>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #C74E3128</Message>
      <Timestamp>2013-03-04T11:08:58.0272169Z</Timestamp>
      <InnerFault>
        <ErrorCode>-2147196411</ErrorCode>
        <ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
        <Message>Cannot create or delete a system AttributeMap.</Message>
        <Timestamp>2013-03-04T11:08:58.0272169Z</Timestamp>
        <InnerFault i:nil="true" />
        <TraceText i:nil="true" />
      </InnerFault>
      <TraceText i:nil="true" />
    </OrganizationServiceFault>


    Monday, March 4, 2013 11:11 AM
  • In your case where you have the same relationship defined twice - you won't be able to delete the default mapping that is generated by the system.

    What you could do - to the field you don't want to map over when creating from the Contact is add some JavaScript non the form OnLoad event when the record is first created to remove the value if present.

    function OnLoad() {
        if (Xrm.Page.ui.getFormType() == 1) {
            if (Xrm.Page.getAttribute("new_exampleid2").getValue() != null) {
                Xrm.Page.getAttribute("new_exampleid2").setValue(null);
            }
        }
    }


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Tuesday, March 5, 2013 4:29 AM
    Moderator
  • Because you have multiple lookups to the same entity, it means the mappings are the same. This is because the mappings for a relationship apply to all relationships between these 2 entities, I believe this has to do with the way CRM opens records from the context of another, as it does not know which grid/relationship you create the child record from, it only knows the ID of the parent created from.

    In other words, you cannot have 2 relationships from the same entity to the same entity with different mappings. Also, as you have witnessed, the lookup fields on the child record to the parent entity will automatically be added to the mappings, and these cannot be removed.

    The only way to remove the second value is by using JavaScript like Jason has mentioned, however this only works well for one of the relationships.

    Paul

    • Marked as answer by Pe.B Tuesday, March 5, 2013 8:14 AM
    Tuesday, March 5, 2013 5:52 AM
  • Hi an thx Jason and Paul,

    ok, even if i think it is not the right way from MS to automatically map all lookups, i think that i will use the js.

    I would prever that MS will not map any, if there are more the one same lookups .. and will say .. in this case use js for the one / or more mappings. Better would be that MS makes this mappings deletable.

    But this are wishes and MS does not care.

    THX .. i hope MS is the solution for me. I'll try.

    Greets Pit

    Tuesday, March 5, 2013 8:19 AM
  • Hi Jason:

    This is my first experience with the JavaScript side of things:  how do I add this code to the Event Handler?  Do I need to create a new function within the Handler Properties?


    Robert McAnally CRM Administrator • BizNet Software

    Tuesday, April 28, 2015 6:50 PM