Thursday, July 9, 2015

How to Close a Form in CRM 2013 using javascript

With reference to CRM 2013 SDK, following is the code snippet to close the form.

Xrm.Page.ui.close();

Please note the following important points.

"The HTML Window.close method is suppressed. To close a form window you 

must use this method. If there are any unsaved changes in the form the user 

will be prompted whether they want to save their changes before the window closes." 

( Ref: CRM 2013 SDK )


Whereas if we need to save the record using javascript, 

we could use the same methods which we were using in CRM 2011.

Xrm.Page.data.entity.save( null | "saveandclose" |"saveandnew" );

 

Arguments values:


save()

If no parameter is included the record will simply be saved. This is the equivalent of using the 

Save command.


save("saveandclose")

This is the equivalent of using the Save and Close command.


save("saveandnew")

This is the equivalent of the using the Save and New command.

( Ref: CRM 2013 SDK )