Dynamics CRM 2011 · Javascript · Workaround

CRM 2011: Text field value not changed until losing focus

I just noticed recently that a text field in CRM form will not have its value updated until I clicked away from the field.

This is an issue simply because if the next step is a ribbon click which validates that field, the crm attribute simply returns null or the previous value.

A workaround for this is to call blur on the html element. I doubt this is supported but this method is supported on all the major browser.

var element = document.getElementById("new_textfield");

Cheers – Sy


6 thoughts on “CRM 2011: Text field value not changed until losing focus

  1. I have this problem but this solution does not solve the issue for me. The value is still unchanged after calling the blur function.

    I have a button on the form that executes a javascript trying to retrieve form field values. But if the control containing the value is still in focus the old value will be returned by the attributes getValue() function.

    Does anyone know how to “commit” the edited value using javascript?

    1. Hi Per,

      I have had the same issue and spent quite an amount of time trying to solve this. In the end I gave up and advise the client to include this in training if the issue or move the function to different event.

      If you have found a solution, please kindly leave a comment.


  2. I put it in the function being called as the button is clicked. The timeout is just for one millisecond so it will not interfere with user experience. The timeout will let the javascript thread release focus from the form field containing the edited value. When the thread returns, one ms later, to execute my code the correct value is available.

    There may be a potential timing issue here if 1 ms in not enough for the thread to release the focus but I have not seen that happen so far.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s