Question

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

Was it helpful?

Solution

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.

OTHER TIPS

There are two possibilities:

  1. I think you should use a form onload event and check if record is created for the first type by Xrm.Page.ui.getFormType()=1 the do not FetchXMl bceause new record is going to be created.

  2. if Xrm.Page.ui.getFormType()=2 then FetchXml

    Or you can use

     setInterval  (function() FetchXML},3000);
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top