Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / MS CRM World / Tricky lost focus event cal...

Tricky lost focus event call in supported way dynamics crm

abhishek_255 Profile Picture abhishek_255 1,612
I had an issue where I need to access CRM text field value on command click. Everything works perfectly well if user clicks on the form after text input (on change event is being called in this case). However things does not work when user hit the command button directly.

I found a solution that perfectly works well in my case. I have done three things

A. I have created a global variable in javascript to hold the state of object when the command button gets clicked.

B. On click of command button I have updated state in global variable and call Xrm.Page.data.save() method.

C. Create a javascript function and call it on form's save event. On save check who has initated the save click i.e. command button or by some other source.


Complete Code- 

var IsCommandClicked= false;

function onSave(context) {
    if (IsCommandClicked== true) {
        IsCommandClicked= false;
        var saveEvent = context.getEventArgs();
        saveEvent.preventDefault();
    }
}

function Command  Click() {
    IsCommandClicked= true;
    Xrm.Page.data.save();
}

Comments

*This post is locked for comments