Thursday, January 10, 2019

D365FO Create Workflows on existing form with Extension

You need to know:
Dynamics 365 for Finance and Operations (AX 7) allows us to extend its functionality through creating extension of elements or creating new elements. Unlike previous versions where we could easily open any OOTB element do whatever changes we wanted (i.e. Customization), D365FO stops us change its OTTB elements through its best practices rules and more extension oriented architecture.

Problem statement:
We can create workflows on both new forms and existing OOTB forms. Because authoring workflows need to modify forms and source table on which workflow is needed we cannot use extension method to enable workflows on existing forms.

Solution summary:
We will create a new table which hold the primary key/ RECID of the target form primary table and the workflow status enum only. Also we perform all workflow related business logic on that table. We then add that table on Data source of the target form which will eventually enable workflow. 
Here is the detail process:







5. Authoring workflows:
Then as usual create workflows on the just created table.



Create workflow category, Query, Type and approval elements. For my practice I created workflow on Transfer order.











6- Event Handlers:

Finally when we are done creating workflow elements. We can write our additional business login on new table like overriding CanSubmitToWorkflow table.
But you may still wonder how will we sync this newly created table with our original table. It is easy. We create an event handler of inserted method of original table. Write logic to inset primary key and workflow status record to new table.
Now enable workflow from workflow editor.

Congratulations! you have successfully created workflow on existing form without doing any customization on OOTB elements. 










1 comment: