As you know there is a service part in dynamic CRM where you can track customers request for product failure or you can define your services, contracts and etc.
To make “Case” more usable for our company`s needs and requirements and make it easier for support team to work with Dynamics CRM, some customization suggested. One of them was to show a grid of records with same serial number of current Case in the Case form.
I did some research and found this useful article, but it did not work in IE and Firefox, I mean the grid is not shown in the form! So why?
Let see how could we show a custom grid (Like what you see in Views of an entity) in a form.
First you should now that by posting a form to “/AdvancedFind/fetchData.aspx” you can get a result containing a view of requested entity. But this form needs some parameters as below:
FetchXml : The query you pass to get data
LayoutXml: The columns you want to be shown on view
EntityName: Entity you want to query
DefaultAdvFindViewId: Id of a default view you created for your custom need
(Notice: This view should have exact columns as you have in LayoutXml)
ViewType: (I dont know :D)
How could you get “FetchXml “?
is it easy, just go to views tab of entity you want to query, click on New Personal View, In saved views find the View you want to use, then click on Download Fetch XML.
For LayoutXml, you can use XrmToolBox, and get layout of view you want.
So what ? As I said the solution provided by the mentioned article, does works perfect in chrome but have problems in IE and firefox. To make it work in those browsers, instead of creating the form dynamically using js code, I hard-coded form elements in string and then post it, as below:
<br /> var innerform='<form name="vDynamicForm" method="post" action="'+ gContext.getServerUrl()+'/AdvancedFind/fetchData.aspx">'+ '<input type="hidden" name="FetchXml" value="'+Instance.FetchXml+'">'+ '<input type="hidden" name="LayoutXml" value="'+Instance.LayoutXml+'">'+ '<input type="hidden" name="EntityName" value='+Instance.Entity+'>'+ '<input type="hidden" name="DefaultAdvFindViewId" value='+Instance.QueryId+'>'+ '<input type="hidden" name="ViewType" value="1039">'+ '</form>';