We can open new Model forms using JavaScript in Dynamics 365 CRM. In this example, we will discuss how to open new modal forms using the new dialog feature. In this article, we will open an account entity as a modal form in the Contact entity. Navigate to the contact form in the front end, open your browser developer console by pressing ‘F12’ and paste the code given below.
If you are in contact entity this will
open new contact form for you. You can also aligned it on your own demand (center
or right)
Input:
Xrm.Navigation.navigateTo({pageType:”entityrecord”,
entityName:”account”, formType:2}, {target: 2, position: 1, width: {value: 50,
unit:”%”}});
Output:
Here
you can see we have opened new account form on contact entity using browser
developer console
It is aligned center now. You can change it as right:
Xrm.Navigation.navigateTo({pageType:”entityrecord”,
entityName:”account”, formType:2}, {target: 2, position: 2, width: {value: 50,
unit:”%”}});
Set position:2 instead of 1:
Here you can see both align center
and align right. If we set position as 1 it will align center can change
position as 2 will change position as right
Minimize & Maximize using the below snapshot:
Change size of the model form using:
We can change the size of the model form by
changing the values given in the code. In the given snapshot you can see the
value is 80. This change value effect on our size of model form.
Open Existing Records:
We can fetch the existing records saved
in an entity by using following code.
Xrm.Navigation.navigateTo({pageType:”entityrecord”,
entityName:”contact”, formType:2,
entityId:”71f0728d-c25f-ea11-a811-000d3a3be299″}, {target: 2, position: 1,
width: {value: 50, unit:”%”}});
We have to fetch this first name and last name in our new modal form.
We can change its position by
changing position value 1 to 2.
We can also check total record
saved in an entity by using given code, for example we can check how many
record in CONTACT entity.
Xrm.Navigation.navigateTo({pageType:”entitylist”,
entityName:”contact”}, {target: 2, position: 1, width: {value: 50, unit:”%”}});
Here we can see the total records
in contact entity. We can change the size of model form and also change the alignment
of that form. Can change center or right. We can also minimize and maximize the
model form by clicking on the top right button.
We can PASS ID to open any record
of contact:
We can open any record by passing
ID by getting from the urn
Xrm.Navigation.navigateTo({pageType:”entitylist”,
entityName:”account”, viewId:” 405996ad-84bb-ea11-a812-000d3a8b3ec6″}, {target: 2, position: 1, width:
{value: 50, unit:”%”}});
We can open WEB RESOURECES ALSO:
You
can create new web resource and open it by using given code.
Advance
setting >> customization >> system customize >> expand
entities >> web resources >> hit on new >> and set its name
and then open it by its name.
Xrm.Navigation.navigateTo({pageType:”webresource”,
webresourceName:”new_MyNewWebResource”},
{target: 2, position: 1, width: {value: 50, unit:”%”}});
0 Comments
Thanks for commenting. Your comment will be live soon after approval.