Hi,
I am trying to set custom filter to one of my subgrids. I can see that setParameter("fetchxml", FetchXml) is unsupported. I found gridcontrol.setFilterXml(filter) from methods of subgrid control. But this does not work and also MSDN doesnot provide documentation for this method.
Can anyone suggest me how to use this method or any workaround to filter the subgrid records dynamically.
This works for me.
function SetReleatedEmailSubgrid(executionContext) {
var isUnified = isUCI();
if (isUnified) {
var formContext = executionContext.getFormContext();
var objSubGrid = formContext.getControl("RelatedEmails");
var entityId = Xrm.Page.data.entity.getId();
if (objSubGrid == null) {
setTimeout(SetReleatedEmailSubgrid(executionContext), 2000);
return;
}
//cc_relatedemailsid is a custom field
var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' returntotalrecordcount='true' page='1' count='4' no-lock='false' >" +
"<entity name='email' >" +
"<attribute name='statecode' />" +
"<attribute name='subject' />" +
"<attribute name='to' />" +
"<attribute name='from' />" +
"<attribute name='statuscode' />" +
"<attribute name='prioritycode' />" +
"<attribute name='createdon' />" +
"<order attribute='createdon' descending='true' />" +
"<filter type='and' >" +
"<condition attribute='cc_relatedemailsid' operator='eq' value='" + entityId + "' />" +
"</filter>" +
"<attribute name='activityid' />" +
"<link-entity name='email' from='activityid' to='cc_relatedemailsid' alias='bb' >" +
"<filter type='and' >" +
"<condition attribute='activityid' operator='eq' value='" + entityId + "' />" +
"</filter>" +
" </link-entity>" +
"</entity>" +
"</fetch>";
objSubGrid.setFilterXml(FetchXml);
objSubGrid.refresh();
}
}
function isUCI() {
return Xrm.Internal.isUci()
}
Hi,
if you want to achieve via supported way,
1.) web resource (html).
2.) you could create multiple pre filter subgrids, and show hide based on conditions. ( Many efforts where there is too many conditions).
Hi LeoAlt,
Thanks for your reply.
Actually am trying to add custom dynamic filter to the sub grid view. Please suggest any supported way to filter it based on a lookup field on the form.
Above provided links specify unsupported way and MSDN does not provide documentation for filtering sub grid view.
Hi Padma,
If you want to custom filter the subgird, I recommend that you could use OOB function to do this without coding.
First of all, we should know that the data list we see in the subgirds are all views of entities. So we could custom configure the view filter conditions.
For example, I want to filter the contact subgrid in account form, so I go to the account form editor and open the subgrid property, we could see that the defult view is "Active Contacts Subgrid View" , so I go to system customizations and open this view's editor, and then click on "Edit Filter Criteria" then we could add filter conditions to the view follow our requriements.
By the way, if you want to us js to do this, you could refer to the following posts.
https://community.dynamics.com/crm/f/117/t/221757
https://community.dynamics.com/crm/f/117/t/221037
Hope it helps.
Best Regards,
Leo
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,902 Super User 2024 Season 2
Martin Dráb 229,302 Most Valuable Professional
nmaenpaa 101,156