One of the powerful features of Dynamics 365 is the ability to open apps, forms, views, dialogs, and reports with a URL. This allows you to create links that can launch specific actions or display specific data in Dynamics 365.
In this blog post, I will show you how to use this feature and provide a use case and a code example.
Building the URL
A common use case for opening apps, forms, views, dialogs, and reports with a URL is to create custom buttons or menus that can trigger workflows or display information based on the context of the user or the record. For example, you can create a button that opens a dialog to create a new contact for an account, or a menu that shows a report of the sales performance of a product.
To open apps, forms, views, dialogs, and reports with a URL, you need to construct the URL with the following format:
The parameters are:
- app: The name of the app to open. This is optional if you want to open the default app.
- pagetype: The type of page to open. This can be entitylist (for views), entityrecord (for forms), webresource (for dialogs), or report (for reports).
- etn: The name of the entity to open. This is required for views and forms, and optional for dialogs and reports.
- id: The ID of the record to open. This is required for forms, and optional for views, dialogs, and reports.
- extraqs: The query string to pass additional parameters to the page. This is optional and depends on the type of page.
For example, to open a dialog that creates a new contact for an account with the ID 12345678-1234-1234-1234-123456789012, you can use the following URL:
https://contoso.crm.dynamics.com/main.aspx?pagetype=webresource&webresource=contoso_/dialogs/newcontact.html&etn=account&id=12345678-1234-1234-1234-123456789012
In this URL, the pagetype is webresource, the webresource is contoso_/dialogs/newcontact.html (a custom web resource that contains the dialog logic), the etn is account, and the id is 12345678-1234-1234-1234-123456789012.
When opening forms programmatically within the application using web resources, use Xrm.Navigation.navigateTo or Xrm.Navigation.openForm instead of window.open. In scenarios outside the application, where access to Xrm.Navigation.openForm or Xrm.Navigation.navigateTo is not available, resort to using window.open or a link to open a specific record or form for a table. It’s important to note that displaying a form within an IFrame embedded in another form is not supported.
Display a view in the application navigation using the Site Map
When customizing the application navigation using the site map, it is advisable to refrain from using the view URL copied from the app, as doing so may result in unexpected outcomes when utilized in a <SubArea> Url parameter.
To exhibit a list of table records within the application for a SubArea, the table column value should be set. This action will display the default view for that table, accompanied by the appropriate title and icon.
If a specific initial default view is desired for a SubArea element, the following Url pattern should be used:
Url=”/main.aspx?appid=e2bc1066-488f-eb11-b1ac-000d3a56ead9&pagetype=entitylist&etn=account&viewid=%7b%7d”
When employing this URL, it is essential to specify suitable values for <Titles> and <Descriptions>, and to designate an icon for the table.
Please note that if the view is specified using the /main.aspx page, the view selector will still be visible. Should the user change the view, Model-driven apps will retain the user’s most recent selection, and the initial default view will be displayed upon closing and reopening the browser.
Conclusion
Using URLs to open apps, forms, views, dialogs, and reports in Dynamics 365 is a powerful feature that improves user experience and enables smooth navigation. By creating URLs with specific parameters, such as app, pagetype, etn, id, and extraqs, custom buttons and menus can trigger workflows, display tailored information, and optimize the presentation of table records.
For more in-depth insights and tutorials on Programming or Dynamics 365 features and customization, check out our posts to further enhance your proficiency and maximize the potential of your skills.
Leave a comment