Hey experts,
I am trying to get all cursists from a particular training (N:N) and from all cursists returned I am trying to retrieve their roles (N:N). I am looking if there is a way to combine these querys:
//GET TRAINEES
StringBuilder linkFetch3 = new StringBuilder();
linkFetch3.Append("<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\" distinct=\"true\">");
linkFetch3.Append("<entity name=\"cref8_cursist\">");
linkFetch3.Append("<attribute name=\"cref8_fullname\"/>");
linkFetch3.Append("<attribute name=\"cref8_cursistid\"/>");
linkFetch3.Append("<link-entity name=\"cref8_opleiding_cref8_cursist\" from=\"cref8_cursistid\" to=\"cref8_cursistid\" visible=\"false\" intersect=\"true\">");
linkFetch3.Append("<filter type=\"and\">");
linkFetch3.Append($"<condition attribute=\"cref8_opleidingid\" operator=\"eq\" value=\"{trainingID}\"/>");
linkFetch3.Append("</filter>");
linkFetch3.Append("</link-entity>");
linkFetch3.Append("</entity>");
linkFetch3.Append("</fetch>");
//GET ROLES IN FOR EACH CURSISTS LOOP
StringBuilder linkFetch4 = new StringBuilder();
linkFetch4.Append("<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\" distinct=\"true\">");
linkFetch4.Append("<entity name=\"cref8_rol\">");
linkFetch4.Append("<attribute name=\"cref8_name\"/>");
linkFetch4.Append("<link-entity name=\"cref8_cursist_cref8_rol\" from=\"cref8_rolid\" to=\"cref8_rolid\" visible=\"false\" intersect=\"true\">");
linkFetch4.Append("<filter type=\"and\">");
linkFetch4.Append($"<condition attribute=\"cref8_cursistid\" operator=\"eq\" value=\"{c.SelectToken("cref8_cursistid")}\"/>");
linkFetch4.Append("</filter>");
linkFetch4.Append("</link-entity>");
linkFetch4.Append("</entity>");
linkFetch4.Append("</fetch>");
Best Regards,
Anthony
did you try to build the query with FetchXML Builder?
WarrenBelz
109
Most Valuable Professional
Michael E. Gernaey
82
Super User 2025 Season 1
MS.Ragavendar
72