0
votes

I need to differentiate between the normal first load/reload/refresh of a CRM 2011 form and the load of the page which is triggered on form save, in the JavaScript Web resource (Form OnLoad event).

Is it possible to achieve this by using the execution context object of the load event and how could it be done? If not, is there any other working solution?

2
You can use form type to differentiate between create and update... msdn.microsoft.com/en-us/library/gg327828.aspx#BKMK_getFormType I'm not sure about refreshes though...Ollie
Could you execute the logic on save (e.g. the auto save) rather than on the on-load? You can check save type: dynamicscrmusualsuspect.blogspot.com/2013/10/…Dave
This is not what I'm trying to do. I need to know whether the form load event was initiated from manual load or from save, in CRM 2011. Thank you.amartine
Consider creating a cookie when the save event fires (the cookie name might be the entity id) that expires after a few seconds and check its existence onload.Adi Katz

2 Answers

0
votes

If I understand correctly, you want to identify when a form is being loaded immediately following a save in client script.

You can't do this using the form type defined in the execution context alone, but you can do it using a custom attribute. I would recommend a Yes/No optionset attribute, for example, call it "WasJustSaved".

In OnLoad, you check if "WasJustSaved" = Yes and execute your logic. At the end of Onload, set it to No if it's Yes. Do this via a service call so as not to trigger the OnSave logic.

In the OnSave, set "WasJustSaved" to Yes.

This solution isn't perfect. If multiple users are working with the record at the same time, it could get confused. And you'll probably have to change the logic if you upgrade to 2013 or the autosave will trigger it.

0
votes

In CRM there are formloads which will give you the type of form whether the create load or update load. So you need add the script when you want it to trigger.

Check the following link. Hope this is what you what you want

http://msdynamicscrmblog.wordpress.com/2013/12/11/get-form-types-and-modes-in-dynamics-crm-2013/