Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

How to create a custom approval Workflow in Dynamics NAV – Part 1

CDsilva Profile Picture CDsilva 4,188

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.

  1. Create a field Approval status with option string as open, released, rejected and pending approval. This field is un-editable
  2. Create Release and Reopen button to manually release and reopen the document
  3. Create Send approval request button and trigger it.
  4. To implement this we first go to approval management codeunit (1535), and create a function named OnSendJobsforApproval

1

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.

2

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

3

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.

4

     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.

5

6

iii. RunWorkflowOnApproveApprovalRequestForJobsCode

This is a global function with return value as code and length 128.

7

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.

8

9

10

We call the codeunit workflow management to handle event

v. RunWorkflowOnRejectApprovalRequestforJobsCode

This is a global function with return value as code and length 128

11

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

12

vii. RunWorkflowOnDelegateApprovalRequestForJobsCode

This is a global function with return value as code and length 128

13

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.

14

15

16

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 was originally posted here.

Comments

*This post is locked for comments