Retrieving updated Value from a Field

Using Xrm.Page.getAttribute("your field name").getValue() we can retrieve the CRM field value. But there are some scenarios, this line of code will give wrong or old value.

Ex. Write something on Subject field and click immediately on button (Webresource button), on onclick of it, try to retrieve the value of this field. It will not give you the update value. After a couple of hours effort found a way to get the updated value in this scenario.

On button click event change the focus to button click event then save the form. Then try to retrieve the field. It will give  you the updated values.

function ButtonClick()
{
Xrm.Page.ui.controls.get("new_button").setFocus();
window.Xrm.Page.data.entity.save();
Xrm.Page.getAttribute("subject").getValue()
}

No comments:

Post a Comment

Featured Post

Improving MS CRM Performance

Performance on MS CRM is always a crucial thing and we may follow different ways to achieve the performance thing. Below is the one more a...