Showing posts with label Extended Workflow. Show all posts
Showing posts with label Extended Workflow. Show all posts

Avoid Over layering in Development of Workflows on Existing Form


Workflow Extension (alternate way)



As we all know 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 a custom workflow on the Transfer order form. as I mentioned that over-layering is not allowed. After few hours of brainstorming within the team, we decided to create a custom workflow with the new table which we will use sort of extension and associate the table with the Transfer order form.

Following are the steps to create a custom workflow and associate it with the existing form.

Prerequisite.
Basic workflow knowledge required. 


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

Reference screenshot.


Step-2 Create a 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 a method in the table to update the 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 the workflow form of your module and click on new to create a new workflow.

You can check in the below screenshot my workflow is appearing.

Reference screenshot.



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

Step-14 Create an 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 the parent data source. in my case parent table was inventTransferTable.

Step-16 Only two types of joins are 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 table Methode OnWritten and insert the record on our newly added data source as well. Whenever users create or update the Transfer table.  In my case invent transfer table was a 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 issues during the implementation of this blog.

Support Faryal's Cusine


Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...