I have a custom workflow activity that accepts a FetchXML string as an input parameter.
I need to execute the Fetch XML up against whatever the current record is.
My fetch XML looks like this:
<fetch> <entity name="cpp_job" > <attribute name="cpp_dateinprogress" /> <attribute name="cpp_dateproposed" /> <attribute name="cpp_datebooked" /> <attribute name="cpp_datecompleted" /> <attribute name="cpp_jobnumber" /> <attribute name="cpp_jobstatusprimary" /> <filter type="and" > <condition attribute="cpp_jobid" operator="eq" value="{0}" /> </filter> </entity> </fetch>
The problem is what when I run the workflow on demand to test it, I get the following error:
Unhandled exception:
Exception type: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]
Message: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> Microsoft.Crm.CrmException: An exception System.FormatException was thrown while trying to convert input value '{0}' to attribute 'cpp_job.cpp_jobid'. Expected type of attribute value: System.Guid. Exception raised: Expected hex 0x in '{0}'.
Why is this giving me an error about the {0} in the filter shown below?
<filter type="and" > <condition attribute="cpp_jobid" operator="eq" value="{0}" /> </filter>
If I manually insert the real GUID, it will run without error, but this will always be run against a different record and we will never know the GUID of that record.
The goal is that the Fetch XML uses "whatever the current record is" based on the operator="eq" value="{0}"
I am basing the use of the {0} on the article that explains it here - practical-crm.blogspot.com/.../workflow-fetchxml-query.html
*This post is locked for comments