Ive been trying to figure out how to assign the FetchXml to the default view of the subgrid but havent had any luck yet. I cant assign the "See the Records associated with this view" view to the subgrid because its an associated view and not a system view.
I also tried using Javascript but I'm unable to get it to return any records at all with that. Using JS as an Onload method and using timeouts and refresh command.
Plugin Code
QueryExpression query = (QueryExpression)context.InputParameters["Query"];
Guid tripId = new Guid();
foreach (LinkEntity lnk in query.LinkEntities)
{
foreach (ConditionExpression con in lnk.LinkCriteria.Conditions)
{
foreach (Guid val in con.Values)
{
tripId = val;
}
}
}
FetchXmlToQueryExpressionRequest req = new FetchXmlToQueryExpressionRequest();
req.FetchXml = "<fetch top='50' >" +
"<entity name='activitypointer' >" +
"<attribute name='createdon' />" +
"<attribute name='activityid' />" +
"<attribute name='prioritycode' />" +
"<attribute name='statecode' />" +
"<attribute name='regardingobjectid' />" +
"<attribute name='subject' />" +
"<filter type='or' >" +
"<condition entityname='customervisit' attribute='originatingtrip' operator='eq' value='"+tripId+"' />" +
"<filter type='or' >" +
"<condition entityname='accountaffected' attribute='originatingtrip' operator='eq' value='"+tripId+"' />" +
"</filter>" +
"</filter>" +
"<link-entity name='accountaffected' from='accountaffectedid' to='regardingobjectid' link-type='outer' />" +
"<link-entity name='customervisit' from='customervisitid' to='regardingobjectid' link-type='outer' />" +
"</entity>" +
"</fetch>";
FetchXmlToQueryExpressionResponse resp = (FetchXmlToQueryExpressionResponse)service.Execute(req);
context.InputParameters["Query"] = resp.Query;