Development

Extended handling of save event in forms with close dialog (like opportunitites)

All developers who developed JavaScripts for CRM read this article. But there is no info about getting data from fields of “Close dialogue” (like opportunity close). I’ve made a little research on this theme and here is the result:

First of all – when you close opportunity event.Mode equals 5 (Deactivate event mode). New state, new status and close info you can get using following scripts placed in OnSave event handler of opportunity form, save form, publish entity:

 

Create and close opportunity with won status:

You will see following result:

If you will try to close opportunity with lost status:

You will get following result:

How this can be used – for example you want make Description field required in the case when opportunity is won and competitor field when opportunity is lost. Put following script to OnSave event handler of opportunity form:

 

Save form and publish opportunity entity. Then try to close opportunity.
Won scenario:


Lost Scenario:


This customizations are not documented so it seems that this is unsupported approach to customization…

5 Comments on “Extended handling of save event in forms with close dialog (like opportunitites)

  1. very informative and helpful post.. it really shows the hard work of Andriy.. it helped me to do customization which i thought, was not possible by supported way before. Thanx Andriy.. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *