How can |I construct a query in QueryExpression which will search by the id of a lookup field?
I have a scenario in which I have an incident with a known ID. I have a custom entity that is linked to the incident. I want to fetch all the related custom entities;
I have tried variations on
EntityReference incident = new EntityReference("incident", caseid); try { utilities.log("List case histories"); QueryExpression CasesQuery = new QueryExpression { EntityName = "qubic_servicemodule_casehistory", ColumnSet = new ColumnSet(true), Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "qubic_servicemodule_case", Operator = ConditionOperator.Equal, Values = { incident } } } } };
and
try { utilities.log("List case histories"); QueryExpression CasesQuery = new QueryExpression { EntityName = "qubic_servicemodule_casehistory", ColumnSet = new ColumnSet(true), Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "qubic_servicemodule_caseid", Operator = ConditionOperator.Equal, Values = { caseid } } } } };
but with no success. Fetching all the attributes for case histories shows me that I have an attribute "qubic_servicemodule_case", which in turn has an attribute which is the id for which I am searching. But how do I write a query to test that? qubic_servicemodule_case, qubic_servicemodule_case.Id and qubic_servicemodule_caseid all fail. Comparing to an entity itself fails so what should I be trying here?