Thursday, July 12, 2018

Avoid Over layering in Development of Workflows on Existing Form

Workflow Extension (alternate way)

As we all knows that over layering is restricted by Microsoft in D365FO and in extension canSubmitToWorkflow not working at all.

Last week, I have received the requirement from my project manager to create custom workflow on Transfer order form. as i mentioned that over layering is not allowed. After few hours of brain storming within team we decided to create custom workflow with new table which we will use sort of extension and associate the table with Transfer order form.

Following are the steps to create custom work flow and associate with existing form.

Basic workflow knowledge required. 

Step-1 Create custom Enum or you can use existing.

Reference screenshot.

Step-2 Create custom table and add two fields Transfer order Id and Status field extend both fields with appropriate Enum or EDTs. In our case Table name is SLD_TransferOrderWorkflow

Reference screenshot.

Step-3 Create relation on Invent Transfer table and our newly created table on the basis of Transfer Order Number.

Reference screenshot.

Step-4 Create Custom Query and Add the SLD_TransferOrderWorkflow table.
Step-5 Create workflow Type.  

Reference screenshot.

Step-6 Create workflow Approval.

Reference screenshot.

Step-7 Drag the workflow approval in workflow type.

Reference screenshot.
Step-8 Override the canSubmitToWorkflow  on SLD_TransferOrderWorkflow.

Reference screenshot.

Step-9 Create method in the table to update status on workflow events/approval.

Reference screenshot.

Step-10 Place proper labels on workflow types, approval and menu items.

Step-11 Build the model and perform the database sync.

Step-12 Now navigate to workflow form of your module and click on new to create new workflow.

You can check in the below screen shot my workflow is appearing.

Reference screenshot.

Step-13 configure workflow as per your requirement and activate.

Step-14 Create extension of the form on which you want to associate workflow. in my case form was inventTransferTable.

Step-15 Add data source table and join with parent data source. in my case parent table was inventTransferTable.

Step-16 Only two type of join supported. Inner and outer.. in my case i am using inner because i don't have previous records.  but recommend outer join if you have previous records.

Reference screenshot.

Step-17 Now override the initialized method of the newly added (SLD_TransferOrderWorkflow)  data-source  and enable the workflow.

Reference screenshot.

Step-18 Now override the parent tabl Methode OnWritten and insert the record on our newly added data-source as well. Whenever user create or update Transfer table.  In my case invent transfer table was parent.

Reference screenshot.

 Step-19 Now build the model and create the new transfer order and verify. for me its working fine without over-layering.

Reference screenshot.

Please feel free to contact me if you are facing any issue during implementation of this blog.


  1. I follow all above steps but Workflow button is not show.

    1. I try to add a vendor creation approval at VendTable, I created a custom table like your steps, but Workflow button is not show. I also create a form for the custom table, and I find workflow button at that form, and I submit record into workflow at my form, finally, I find workflow button at VendTable too.