locked
CRM 4.0 - OnChange Event not triggered as expected RRS feed

  • Question

  • Hi all,

    we have the following problem in a customer environment.

    We implemented the following OnChange-Event in a text field (nvarchar):

        crmForm.all.new_testfield.DataValue = crmForm.all.new_testfield.DataValue.toUpperCase();

    On the CRM server everything is working fine.
    The text is transitioned every time you change the Text in the field "TestField" ("new_testfield").

    On a client computer and on another server the script is not running as expected. (See details reagarding this test computers below.)
    The text is not transitioned in a special scenario (see steps to repro).

    Steps to Repro (client computer):
    1. Open the form.
    2. Enter text (e.g. "Test") in the field "TestField" ("new_testfield").
    3. Move via "Tab" to the next field.
    The text is transitioned as expected (e.g. "TEST").

    4. Move back to the field "TestField".
    5. Enter the same text as in step 3 (e.g. "Test") in the field "TestField" ("new_testfield").
    6. Move via "Tab" to the next field.
    The text is not transitioned any more.

    7. Move back to the field "TestField".
    8. Enter the other text as in step 3 (e.g. "TestTest") in the field "TestField" ("new_testfield").
    9. Move via "Tab" to the next field.
    The text is transitioned as expected (e.g. "TESTTEST").

    We can reproduce this steps on our test environment with the same customizings, too.

    Why is the event not triggering in step 5/6 on the client computer?

    Some parameters:
    CRM server: Windows Server 2008 R2, Internet Explorer 8
    Client computer: Windows XP Pro, Internet Explorer 6
    Other server (which we used for this test): Windows Server 2003 R2, Internet Explorer 6

    Regards,
    Katrin Schulz

    • Moved by Kimberlee Johnson Tuesday, May 24, 2011 1:37 PM jscript question (From:Dynamics CRM)
    Tuesday, May 24, 2011 1:08 PM

Answers

  • Hello Katrin,

    Try to put following code to OnLoad event handler:

    function TextToUpper(ElementId)
    {
      var element = document.getElementById(ElementId);
      if (element != null)
        element.attachEvent("onkeyup", function()
    {
      var strPass = element.value;
      if (strPass == null)
        return;
      
      element.value = strPass.toUpperCase();
    });    
    }
    
    TextToUpper('field for uppercase here');
    


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by Faisal Fiaz Tuesday, May 24, 2011 2:34 PM
    • Marked as answer by Katrin Schulz Thursday, May 26, 2011 9:48 AM
    Tuesday, May 24, 2011 1:57 PM
    Moderator

All replies

  • Hello Katrin,

    Try to put following code to OnLoad event handler:

    function TextToUpper(ElementId)
    {
      var element = document.getElementById(ElementId);
      if (element != null)
        element.attachEvent("onkeyup", function()
    {
      var strPass = element.value;
      if (strPass == null)
        return;
      
      element.value = strPass.toUpperCase();
    });    
    }
    
    TextToUpper('field for uppercase here');
    


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by Faisal Fiaz Tuesday, May 24, 2011 2:34 PM
    • Marked as answer by Katrin Schulz Thursday, May 26, 2011 9:48 AM
    Tuesday, May 24, 2011 1:57 PM
    Moderator
  •  

     

    OR you can try this: (this is just a concept you may modify the code if it works)

    if(crmForm.all.new_testfield.IsDirty)

         crmForm.all.new_testfield.DataValue = crmForm.all.new_testfield.DataValue.toUpperCase();

    else

         crmForm.all.new_testfield.DataValue = crmForm.all.new_testfield.DataValue.toUpperCase();


    AAVI
    Tuesday, May 24, 2011 2:31 PM
  • Thanks Andriy a33ik Butenko and AAVI for your fast answers.

    We tried both scripts and this one (from Andriy a33ik Butenko) fixed our problem.

    Thursday, May 26, 2011 9:51 AM