1. create subgrid of activity on from without any filter.
2. Then override subgrid by below code. change fetch query according to you.
3. call this function onload of from.
function
filterSubGrid() {
varworkflowTemplatetValue = Xrm.Page.getAttribute("ymf_workflowtemplateid").getValue();
//field to filter by
varworkflowTemplatetGrid = document.getElementById("WorkflowTemplateSteps");
//grid to filter
if(workflowTemplatetGrid ==
null) {
//make sure the grid has loaded
setTimeout(
function() { filterSubGrid(); }, 2000);
//if the grid hasn’t loaded run this again when it has
return;
}
varworkflowTemplatetValueid =
"00000000-0000-0000-0000-000000000000";
//if filter field is null display nothing
if(workflowTemplatetValue !=
null) {
workflowTemplatetValueid = workflowTemplatetValue[0].id;
}
//fetch xml code which will retrieve all the accounts related to the contact
varfetchXml =
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
" <entity name='ymf_workflowtemplatestep'>"+
" <attribute name='ymf_name' />"+
" <attribute name='ymf_code'/>"+
" <attribute name=ymf_workflowtemplatestepid' />"+
" <order attribute='ymf_code' descending='false' />"+
" <filter type='and'>"+
" <condition attribute='statecode' operator='eq' value='0' />"+
" <condition attribute='ymf_workflowtemplateid' operator='eq' value='"+
workflowTemplatetValueid + "' />"+
" </filter>"+
" </entity>"+
"</fetch>";
workflowTemplatetGrid.control.SetParameter(
"fetchXml", fetchXml);
//set the fetch xml to the sub grid
workflowTemplatetGrid.control.refresh();
//refresh the sub grid using the new fetch xml
}
Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"