top of page
pedroairo9

CRM 2015 – Javascript – Opening an Entity Form from Javascript




Opening a form where you can say if it will open on the same window or another window it will be possible on the Microsoft Dynamics CRM Online 2015 Update 1.


In old times you would use the window.open, but my Microsoft and say as well as a best practice you should use the Xrm.Utility (client-side reference).


Now it will be possible to pass if you want to open on the same window or in a new window as you can see from the below information that i took from the MSDN.



Opens an entity form for a new or existing entity record using the options you set as parameters.







Xrm.Utility.openEntityForm(name,id,parameters,windowOptions)   Parameters    

Name Type Required Description

name

String

Yes

The logical name of the entity.

id

String

No

The string representation of a unique identifier or the record to open in the form. If not set, a form to create a new record is opened.

parameters

Object

No

A dictionary object that passes extra query string parameters to the form. Invalid query string parameters will cause an error.

Valid extra query string parameters are:

  1. Form id : To set the id value of the main form to use when more than one form is available. The parameter is formid .

  1. Default field ids : To set default values for a new record form. For more information, see Set field values using parameters passed to a form .

  1. The navbar and cmdbar parameters described in Query String Parameters for the Main.aspx Page .

  1. Custom query string parameters : A form can be configured to accept custom query string parameters. For more information, see Configure a form to accept custom querystring parameters .

windowOptions

Object

No

For Microsoft Dynamics CRM Online 2015 Update 1 or later use this optional parameter in the web application to control how the form opens. You can choose to open a form in a new window by passing a dictionary object with a boolean openInNewWindow property set to true . Remarks Using this function helps ensure that users are not prompted to log in again under certain circumstances. Examples Open a new account record using the default form







Xrm.Utility.openEntityForm( "account" ); 

Open an existing account record using the default form







Xrm.Utility.openEntityForm( "account" , "A85C0252-DF8B-E111-997C-00155D8A8410" ); 

Open a new account record with a specific form and setting default values







 var  parameters = {};parameters[ "formid" ] = "b053a39a-041a-4356-acef-ddf00182762b" ;parameters[ "name" ] = "Test" ;parameters[ "telephone1" ] = "(425) 555-1234" ;Xrm.Utility.openEntityForm( "account" , null , parameters); 

Open a new account record using the default form in a new window







 var  windowOptions = { openInNewWindow: true };Xrm.Utility.openEntityForm( "account" , null , null ,windowOptions); 

Hope it helps.




4 views0 comments

Recent Posts

See All

Comments


bottom of page