CRM 2011: CustomView for regardingobjectid leads to XML error

Answered CRM 2011: CustomView for regardingobjectid leads to XML error

  • Montag, 27. Juni 2011 16:25
     
      Enthält Code
    Hi,

    I'm having a problem when creating a new view for the lookup dialog of the field "regardingobjectid" in the entity "serviceappointment" via the jScript method addCustomView(). Selecting another entity type in "Look for" after having displayed the custom view leads to the error "Entity Name specified in FetchXml does not match the entity name in the EntityExpression". When I select another system view in the same entity type as the custom view first, I can switch to the other entity types without any problems.

    The jScript code for defining the view in the onLoad of serviceappointment is:

        var viewId = "{C5C26189-68CD-4dd9-8619-22CAB0078D12}";
        var entityName = "test_project";
        var viewDisplayName = "Test";
        var fetchXml = "<fetch version='1.0' " +
                "output-format='xml-platform' " +
                "mapping='logical'>" +
                  "<entity name='test_project'>" +
                    "<attribute name='test_customerid' />" +
                    "<attribute name='test_matchcode' />" +
                    "<attribute name='test_projectnumber' />" +
                    "<attribute name='test_projectid' />" +
                    "<order attribute='test_customerid' " +
                        "descending='false' />" +
                    "<filter>" +
                      "<condition attribute='test_customerid' " +
                            "operator='eq' " +
                            "value='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' />" +
                    "</filter>" +
                  "</entity>" +
                "</fetch>";
    
        var layoutXml = "<grid name='resultset' " +
                   "object='1' " +
                   "jump='test_projectnumber' " +
                   "select='1' " +
                   "icon='1' " +
                   "preview='1'>" +
                 "<row name='result' " +
                   "id='test_projectid'>" +
                  "<cell name='test_customerid' " +
                     "width='200' />" +
                  "<cell name='test_projectnumber' " +
                     "width='200' />" +
                  "<cell name='test_matchcode' " +
                     "width='100' />" +
                 "</row>" +
                "</grid>";
        var lookupControl = Xrm.Page.getControl("regardingobjectid");
        lookupControl.addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, false);
    
    

           
    What am I doing wrong?

    Thanks,

    Hendrik

Alle Antworten

  • Samstag, 30. Juni 2012 08:17
     
     

    hi there, i have the same problem with you

    Have you found the solution :( ?

  • Dienstag, 11. September 2012 16:02
     
     Beantwortet

    This appears to be a bug, but until it gets fixed, I modified the lookupinfo.aspx

    In my situation, i simply need to swich the object type to users after the custom view was added to contact. Your situation, you would change it to lead... Heres what i did to fix it:

    Note: this is an UNSUPPORTED customization/workaround

    1. change the lookupinfo.aspx file located on the crmwebsite:

    C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_controls\lookup

    2. modify the function: OnRecordTypeChange

    function OnRecordTypeChange(oSelect, bFromOnLoad)
    {
    if (bFromOnLoad)
    {
    var findCriteria = document.getElementById("crmGrid_findCriteria");
    if (!IsNull(findCriteria) && findCriteria.value != "")
    {
    isSearchOn = true;
    }
    }
    if (typeof(showMyRecordsSpan) == "object")
    {
    if (_showMyRecordsFilter[oSelect.value])
    {
    showMyRecordsSpan.style.display = "inline";
    }
    else
    {
    showMyRecordsSpan.style.display = "none";
    }

    //This is a crm bug when switching objects from a custom fetch xml view of a different object type.
    // Contact has custom fetchxml > switching to user will throw error unless we set the default user view

    if (oSelect.value == 8) //user
    {

    crmGrid.SetParameter("viewid", "{00000000-0000-0000-00AA-000010001004}"); //point to any view in system
    crmGrid.SetParameter("fetchXml", "");
    crmGrid.SetParameter("layoutXml", "");
    crmGrid.Reset();

    }

  • Donnerstag, 13. September 2012 13:33
     
     Beantwortet

    the above breaks the assign lookup, adding one more condition fixes the issue:

    if (oSelect.value == 8) //user
    {

    if (crmGrid.GetParameter("viewid") == "{00000000-0000-0000-0000-000000000000}")
    {

    crmGrid.SetParameter("viewid", "{00000000-0000-0000-00AA-000010001004}"); //point to any view in system
    crmGrid.SetParameter("fetchXml", "");
    crmGrid.SetParameter("layoutXml", "");
    crmGrid.Reset();

    }

    }

  • Donnerstag, 13. September 2012 13:51
    Moderator
     
     
    Nice trick, Ryan. Thanks for sharing.

    Freelance Developer for Dynamics CRM 4.0/2011

  • Donnerstag, 13. September 2012 13:52
     
     

    Hi.

    Again, CRM 2011 Rollup 10 has already included the fix.

    • Views that are added to a lookup dialog box by using the addCustomView function from the Microsoft Dynamics CRM 2011 Software Development Kit (SDK) do not use default sorting. However, the default sorting that was defined as part of the FetchXml schema that was passed to the function should be used.
    • The AddCustomView method from SDK does not work on a multi-entity lookup as expected.

    Jaimie

  • Montag, 20. Mai 2013 16:42
     
     

    We're on rollup 12, and still having this issue.