Call the javascript function after saving a form in CRM 2011

advertisements

I am new to CRM 2011. I created a javascript function in the Common.js file. This function will be called in other functions from many forms. Also this function contains FetchXML queries. In each form I created a specific function that contains a call to my generic function.I call this specific function on the OnSave event of a form. The issue is, when I call the specific function on the save, in the generic function I'll do a FetchXML query of the entity I just saved, BUT the FetchXML query returns the values before the saving has happened (The entity I just saved which called the function that has the FetchXML query, I can't see the changed attributes with their new values in the result of the FetchXML query!). I tried another solution, instead of calling the specific function from the OnSave Dialogue, I used the method Xrm.Page.data.entity.addOnSave(My specific function) to be sure that it will be called after the form is saved but it's still fetching the old values. Could you please help me out?

Thanks, Walloud


Xrm.Page.data.entity.addOnSave will add a function inside the OnSave event, this means will still be executed before the record is saved.

I suggest to move the logic inside a plugin.