Wednesday 28 September 2016

Unable to edit AX7 element properties (dimmed/grayed out)

Quick tips: In AX2012 and the version before, when you click on an element in the AOT, (assuming the properties window is opened) they're editable right away. But in AX7, if you click on an element in your project, the properties is not editable (grayed out, read only). You'll need to double click to open the element in the editor window, then the properties will be enabled for editing.

Tuesday 20 September 2016

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

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


Details
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.