locked
Custom Entity Owner Lookup Problem RRS feed

  • Question

  • Hope someone is able to help me here. I have a custom entity that I'm having a small problem with when I try to change the Owner of the record.

    If I create a record but do not save it and change the Owner at this point then the record will save correctly and close without issue. However, if I've already saved the record and then try to change the Owner of the record (by using the lookup dialog), I can choose the new Owner and click on OK but the same dialog comes back up but with no owner choice in it. If I look behind the pop-up I can see that my Owner has been updated as expected but why am I getting the pop-up asking me again? If I choose Cancel then the pop-up disappears and the form saves itself for some reason (there is no onChange event being fired on this field) and all is well.

    If however I get this problem and then try and select the new Owner again (instead of clicking Cancel) then I can do this 4 times before the pop-up disappears and nothing is added to the main form as the Owner. If however I click Cancel from the second time on the I recieve an error dialog:

    Stack overflow at line:0

    If I type in the new owner instead of using the pop-up dialog then the lookup works correctly as well, even after I've saved the record. It just works as expected.

    On my form I also have a field called Staff Member and this is also a lookup to the User records of our system but both fields can (and probably will) be different from each other. Not sure if this is also causing the problem.

    I've already updated the Server to RU9 so the problem that has been address with onChange events and Duplicate Detection should have been resolved here.

    Anyone know what I could check next?

    Tuesday, April 13, 2010 11:21 AM

Answers

  • I've seen lookup issues on entities related to javascript.  Disable all javascript on the entity (Onload, Onchange, Form Properties, etc.) and see if the issue is resolved.  Be sure to publish your changes when you disable the scripts and before you test. 

    Regards, Donna

           

    • Proposed as answer by Donna EdwardsMVP Wednesday, April 14, 2010 12:34 PM
    • Marked as answer by u101440 Wednesday, April 14, 2010 1:01 PM
    Tuesday, April 13, 2010 10:49 PM

All replies

  • Did you try to use the actions menu then assign instead of updating directly the owner field?

     


    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete LauncherView Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly RecoveryAnd others (use tool tag on my blog)
    Tuesday, April 13, 2010 11:47 AM
    Moderator
  • Thanx for that. This works as well. So if I write into the field or use this method it works but what is the problem with using the lookup facility? This is still throwing up the problem and it's how most of the users I have know how to use it.

    Tuesday, April 13, 2010 12:39 PM
  • I've seen lookup issues on entities related to javascript.  Disable all javascript on the entity (Onload, Onchange, Form Properties, etc.) and see if the issue is resolved.  Be sure to publish your changes when you disable the scripts and before you test. 

    Regards, Donna

           

    • Proposed as answer by Donna EdwardsMVP Wednesday, April 14, 2010 12:34 PM
    • Marked as answer by u101440 Wednesday, April 14, 2010 1:01 PM
    Tuesday, April 13, 2010 10:49 PM
  • Thanx again for this. I've removed all the javascript and it would work properly. I then started to add each element back into the form one at a time, saving and publishing between each trial. I've found where I think the problem is appearing but I'm unsure how or even if it can be resolved.

    On the form OnLoad event I am calling 2 OnChange events tied to 2 fields on my form:

    var QUICKCREATEFORM = 5;

    if ( crmForm.FormType != QUICKCREATEFORM )
    {
     crmForm.all.new_contactnameid.FireOnChange();
     crmForm.all.new_staffmemberid.FireOnChange();
    }

    These 2 OnChange events are pretty similar in style and simply disable the other field if one is populated and removes the required element on the form from the other field like so:

    var QUICKCREATEFORM = 5;
    var CRM_REQUIRED_LEVEL_NORMAL = 0;
    var CRM_REQUIRED_LEVEL_RECOMMENDED = 1;
    var CRM_REQUIRED_LEVEL_REQUIRED = 2;

    if ( crmForm.FormType != QUICKCREATEFORM )
    {

     // Date: 22 March 2010
     // Purpose: Disable User field if Contact is selected
     
     var oContact = crmForm.all.new_contactnameid;
     var oUser = crmForm.all.new_staffmemberid;
     
     if (oContact.DataValue != null)
     {
      oUser.Disabled = true;
      crmForm.SetFieldReqLevel("new_contactnameid", CRM_REQUIRED_LEVEL_REQUIRED);
      crmForm.SetFieldReqLevel("new_staffmemberid", CRM_REQUIRED_LEVEL_NORMAL);
     }
     else
     {
      oUser.Disabled = false;
      crmForm.SetFieldReqLevel("new_contactnameid", CRM_REQUIRED_LEVEL_REQUIRED);
      crmForm.SetFieldReqLevel("new_staffmemberid", CRM_REQUIRED_LEVEL_REQUIRED);
     }

     if (oContact.DataValue != null && oUser.DataValue != null)
      {
       oUser.Disabled = false;
       oContact.Disabled = false;
       crmForm.SetFieldReqLevel("new_contactnameid", CRM_REQUIRED_LEVEL_REQUIRED);
       crmForm.SetFieldReqLevel("new_staffmemberid", CRM_REQUIRED_LEVEL_REQUIRED);
      }

     // Date: 22 March 2010
     // Purpose: Fire the onChange event associated with Declaration Made

     new_declarationmade_onchange0();

    } // END

    Anyone able to see from these what could be causing the problem?

    Wednesday, April 14, 2010 11:15 AM
  • You might receive more response if you close this post as answered and start a new one that is titled something like Javascript OnLoad interferring with lookup fields.

    Regards, Donna

           

    Wednesday, April 14, 2010 12:37 PM