Tuesday, 20 September 2016

Workflow error - The condition could not be evaluated. No data has been returned

Stopped (error): X++ Exception: The condition could not be evaluated. No data has been returned.
 at SysWorkflowEvaluationProvider-evaluateCondition

During one of the workflow development, the requirement is to have a batch job to auto-submit all records that meet certain condition. Let's call this TableA for now, auto-submit all records where FieldA == 12. Then workflow configuration is set to auto-approve records if certain conditions are met.

The development started with creating a query object.
Then use this query in the Workflow wizard and created all the related classes, menu item, etc.
Then a batch job created to auto-submit all TableA records which FieldA == 12.
The batch job uses the same query object created earlier.
And the mistake is the FieldA is added into the query object as a range field with fixed enum value 12.

This is due to during the workflow approval process, this FieldA will be updated into other status.
When it is updated to other status than 12, this causes the record doesn't meet the criteria (Range) in the query object, hence, the error "The condition could not be evaluated. No data has been returned.".

The query object (used in workflow document class) is used throughout the approval process, not just the initial submission. So the query shouldn't have any conditions added to it, especially those field which the value will change throughout the process. To fix this, the range (FieldA = 12) has been removed from the query object. Then added during runtime of the batch job. Eg. SysQuery::findOrCreateRange(qbds, fieldNum(TableA,FieldA)).value(...).

For my scenario, the error can be replicated from: (Module) > Setup > **** workflows > (Select the related workflow> Edit > Properties > Automatic actions > Test.

No comments:

Post a Comment