Hello All ,
Why i am writing this below Post ,I gone through the different post not found suitable answer for Subgird Filter in MS CRM using Javascript
MS CRM Version : Dynamics 365 Online v 9.0
I am using Form-context instead of Xrm.Page why because it is deprecated in V 9.0
Please find below link to under stand the Form Context.
https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/clientapi-form-context
User need check the below check box,to Pass Execution Context
function subgirdFilter(executionContext)
{
var formContext = executionContext.getFormContext(); // get formContext
// Case_Activities is Sub Grid Name
var caseActivities = formContext.getControl("Case_Activities");
if (caseActivities == null) {
// Wait one second before recalling the function
setTimeout(subgirdFilter, 1000);
return;
}
var IRCId = formContext.data.entity.getId();
// Build Fetch statement
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='activitypointer'>" +
"<attribute name='subject' />" +
"<attribute name='ownerid' />" +
"<attribute name='activitytypecode' />" +
"<attribute name='statecode' />" +
"<attribute name='instancetypecode' />" +
"<attribute name='community' />" +
"<attribute name='description' />" +
"<attribute name='activityid' />" +
"<order attribute='subject' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='isregularactivity' operator='eq' value='1' />" +
"<filter type='or'>" +
"<condition attribute='regardingobjectid' operator='eq' uitype='brent_ic_complaintsinformationrequest' value='" + IRCId + "' />" +
"</filter>" +
"</filter>" +
"<link-entity name='email' from='activityid' to='activityid' visible='false' link-type='outer' alias='email_engagement'>" +
"<attribute name='isemailfollowed' />" +
"<attribute name='lastopenedtime' />" +
"<attribute name='delayedemailsendtime' />" +
"</link-entity>" +
"</entity>" +
"</fetch>";
// Update the Subgrid with the new FetchXml and refresh the grid
if (caseActivities != null)
{
caseActivities.getGrid().setParameter("fetchXml",fetchXml);
caseActivities.refresh();
}
}
Above code will Work for Filter the "Sub Grid " with Fetch Xml.
Why i am writing this below Post ,I gone through the different post not found suitable answer for Subgird Filter in MS CRM using Javascript
MS CRM Version : Dynamics 365 Online v 9.0
I am using Form-context instead of Xrm.Page why because it is deprecated in V 9.0
Please find below link to under stand the Form Context.
https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/clientapi-form-context
User need check the below check box,to Pass Execution Context
function subgirdFilter(executionContext)
{
var formContext = executionContext.getFormContext(); // get formContext
// Case_Activities is Sub Grid Name
var caseActivities = formContext.getControl("Case_Activities");
if (caseActivities == null) {
// Wait one second before recalling the function
setTimeout(subgirdFilter, 1000);
return;
}
var IRCId = formContext.data.entity.getId();
// Build Fetch statement
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='activitypointer'>" +
"<attribute name='subject' />" +
"<attribute name='ownerid' />" +
"<attribute name='activitytypecode' />" +
"<attribute name='statecode' />" +
"<attribute name='instancetypecode' />" +
"<attribute name='community' />" +
"<attribute name='description' />" +
"<attribute name='activityid' />" +
"<order attribute='subject' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='isregularactivity' operator='eq' value='1' />" +
"<filter type='or'>" +
"<condition attribute='regardingobjectid' operator='eq' uitype='brent_ic_complaintsinformationrequest' value='" + IRCId + "' />" +
"</filter>" +
"</filter>" +
"<link-entity name='email' from='activityid' to='activityid' visible='false' link-type='outer' alias='email_engagement'>" +
"<attribute name='isemailfollowed' />" +
"<attribute name='lastopenedtime' />" +
"<attribute name='delayedemailsendtime' />" +
"</link-entity>" +
"</entity>" +
"</fetch>";
// Update the Subgrid with the new FetchXml and refresh the grid
if (caseActivities != null)
{
caseActivities.getGrid().setParameter("fetchXml",fetchXml);
caseActivities.refresh();
}
}
Above code will Work for Filter the "Sub Grid " with Fetch Xml.
Picchi ekkinchev bhayya
ReplyDelete