Introduction:
If we require approval process for Purchase, Sales orders etc we enable the standard workflows of Dynamics NAV….but if we have a Custom designed page in NAV and we need approval workflows how will the workflow process work? How to set it up?
This blog provides a step wise procedure how to create custom workflow from scratch.
This Workflow is enabled for the Jobs page in NAV. We create a button called ‘Send approval Request’ to send the document in this case job document for approval to the approver and on approval from the approver to release the job document.
Here on click of send approval request button, the approval status changes to Pending approval and request is sent to the approver.
The approver logs into the system, he has an option to approve or reject the approval request. On approval the status of the job document changes to release and on reject button the job document changes the approval status to open.
Pre-requisites :
Microsoft Dynamics NAV 2017
Steps.
- Create a field Approval status with option string as open, released, rejected and pending approval. This field is un-editable
- Create Release and Reopen button to manually release and reopen the document
- Create Send approval request button and trigger it.
- To implement this we first go to approval management codeunit (1535), and create a function named OnSendJobsforApproval
In the properties for this, we set the Event as a publisher and event type as Integration. We then subscribe to this function in ‘Workflow Event Handling’ which will be explained later in this document.
In the Locals we create a parameter to Job record and enable the Var field.
5. We create two more global functions, IsJobsWorkflowEnabled , CheckJobsWorkflowEnabled to check whether the workflow is enabled. And a local function to ShowJobApprovalStatus. This function displays messages
6. Now we need to create Events for the workflows hence in the workflow event handling (Codeunit no 1520) we create functions.
7. These event are selected in the front end and based on condition we set an appropriate response for it.
i. RunWorkflowOnSendJobsforApprovalCode This is a global function with return value as code and length 128.
ii. RunWorkflowOnSendJobsforApproval
This is a global function which is a subscriber to the Publisher Integration event created in codeunit Approval Magmt OnSendJobsforApproval, also create a parameter for record job.
iii. RunWorkflowOnApproveApprovalRequestForJobsCode
This is a global function with return value as code and length 128.
iv RunWorkflowOnApproveApprovalRequestforJobs
This is a global function which is a subscriber to the Publisher Integration event created in codeunit Approval Mgmt OnApproveApprovalRequest and create parameter record Approval Entry.
We call the codeunit workflow management to handle event
v. RunWorkflowOnRejectApprovalRequestforJobsCode
This is a global function with return value as code and length 128
vi. RunWorkflowOnRejectApprovalRequestforJobs
This is a global function which is a subscriber to the Publisher Integration event created in codeunit Approval Mgmt OnRejectApprovalRequest and create parameter record Approval Entry
vii. RunWorkflowOnDelegateApprovalRequestForJobsCode
This is a global function with return value as code and length 128
viii. RunWorkflowOnDelegateApprovalRequestForJobs
This is a global function which is a subscriber to the Publisher Integration event created in codeunit Approval Mgmt OnDelegateApprovalRequest and create parameter record Approval Entry.
Next step is how to add the function to Library and how to configure it. This will continue in my next blog post in Part -2. Stay tuned!
*This post is locked for comments