How do I query using the string value for an entity reference object?
QueryExpression query = new QueryExpression(\"entityName\");
query.Criteria = new FilterExp
While it appears that we're out of luck on getting the "like" operator to compare a string to a GUID on the fly, there are at least a couple potential workarounds:
Here's code I use in a workflow that does exactly what I'm describing (i.e. populates the GUID into a text field). It sets an output parameter to the GUID, then the next step of the workflow populates that value into the field.
public partial class GetGuid : BaseWorkflow
{
[Output("Entity Id")]
public OutArgument EntityId { get; set; }
protected override void ExecuteInternal(LocalWorkflowContext context)
{
EntityId.Set(context.CodeActivityContext, context.WorkflowContext.PrimaryEntityId.ToString());
}
}
Please also note that while the "like" operator doesn't work for GUID's, "greater than" and "less than" do, so something like this works: