Saturday, April 16, 2011

Javascript inconsistency with Xrm.Page model

While doing ribbon customization today I found an interesting issue with how the new Xrm.Page model introducted in CRM 2011.

I have a ribbon button which simply fires a javascript function:

function lookup_form() {
    alert(Xrm.Page.getAttribute("dc_openform").getValue());
    alert(crmForm.all.dc_openform.DataValue);
}

I would type a value into my dc_openform field, and click the ribbon button. The first alert would show what was *previously* in the field, while the second alert showed what is *currently* in the field. If I clicked off the field then click the button again, the values match up.

Thus, it appears the the Xrm.Page model is only updated onChange, and that onChange is not fired between typing into a field and clicking the Ribbon button.

No comments:

Post a Comment