Sunday, November 20, 2011

Microsoft Dynamics CRM 2011 crmForm workaround


There is a problem when checking attributes value, after the user clicks on ribbon button without losing focus of the attribute.

Description:

1) I've register the ribbon button event to something like:
if(Xrm.Page.getAttribute("new_test").getValue() != null)
{
alert("aaaaa");
2) User clicks the ribbon button when the attribute is empty
3) Get's alert
4) User insert text to the attribute and clicks again 
5) Get's alert

When user isn't getting out (clicks out side) of the attribute's textbox the value, gets from Xrm.Page.getAttribute("xxxx").getValue(), remains the old value but if he does (just click out side the textbox) everything works.

After changing the code to the old (CRM 4) javascript syntact:
if(crmForm.all.new_test.DataValue != null)
{
     alert("AAAA");
}

Everything worked great! Even when the focus still on the textbox.

This is a workaround.

2 comments:

  1. thx but that's not supported by Microsoft to use a deprecated API

    ReplyDelete
    Replies
    1. Yep you are right...
      Event tried it yet but another option would be set focus on some other control before getting the value from that control...

      Delete