Hi,
I have a form for the table Project on which I have a subgrid for the table Objective (through one of its views). Objective has a lookup field for Phase. I want to apply a FetchXml query to the subgrid to filter on a specific Phase. I am able to find both the lookup string (eg. "Exploration") and the GUID stored in the Phase column of Objective referring to the lookup string. Right now I'm just trying to hard code the FetchXml string to filter the subgrid. This is what I've got:
SubGridFilterExecution = function (executionContext) {
var formContext = executionContext.getFormContext();
var gridContext = formContext.getControl("Subgrid_objectives");
var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='cr047_objective'>" +
"<attribute name='cr047_Name' />" +
"<attribute name='cr047_Description' />" +
"<attribute name='cr047_Objectivemet' />" +
"<attribute name='cr047_Mandatory' />" +
"<filter type='and'>" +
"<condition attribute='cr047_phase' operator='eq' value='{1c73-35c2-ec11-983f-6045bd948406}' />" +
"</filter>" +
"</entity>" +
"</fetch>";
gridContext.setFilterXml(FetchXml);
formContext.getControl("Subgrid_objectives").refresh();
}
This renders zero rows in the subgrid. Removing the <filter> part of the string returns all rows, so the overall mechanics of the script seems to be OK.
Any help greatly appreciated!
Hi
How do I Wire this into my Grid ?
Thanks
Nigel
@Rydman Do you know in similar context, how to get Main Grid context using Javascript. Your example is demonstrating about subgrid. I am struggling to get the main grid context and get FecthXML from main grid context. Let me know please.
Thanks
Ramesh Mukka
Hi @Rydman ,
Can we use this undocumented method in our implementations?
Hi,
My code is OK except for one small detail. My now working code looks like below. The only difference is that the curly brackets from the GUID are gone. Next step is to retrieve the GUIDs dynamically, but I'll google that before turning to the community 🙂
SubGridFilterExecution = function (executionContext) {
var formContext = executionContext.getFormContext();
var gridContext = formContext.getControl("Subgrid_objectives");
var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='cr047_objective'>" +
"<attribute name='cr047_Name' />" +
"<attribute name='cr047_Description' />" +
"<attribute name='cr047_Objectivemet' />" +
"<attribute name='cr047_Mandatory' />" +
"<filter type='and'>" +
"<condition attribute='cr047_phase' operator='eq' value='82ed1c73-35c2-ec11-983f-6045bd948406' />" +
"</filter>" +
"</entity>" +
"</fetch>";
gridContext.setFilterXml(FetchXml);
formContext.getControl("Subgrid_objectives").refresh();
}
WarrenBelz
85
Most Valuable Professional
Michael E. Gernaey
65
Super User 2025 Season 1
mmbr1606
55
Super User 2025 Season 1