Introduction: Workflows are created in Dynamics NAV which when enabled perform a series of steps one after the other automatically and carry out actions as specified in the workflow. Workflow consists of a series of workflow events which get triggered on specific conditions and workflow responses for each event. We often have a requirement to create a new workflow which is not present in the standard workflow from the template list.
Pre-Requisite:
Microsoft Dynamics NAV
Purpose: In this article I will be giving the procedure in Dynamics NAV development exvironment to create a custom workflow by creating new functions in Dynamics NAV and implementing new workflow events. I will be creating a customized Job workflow.
Procedure:
- In table 167 i.e. Job table, I have created a new field ‘Approval Status’.

- The properties of the above field is as follows:

- Go to Codeunit 1535 Approvals Mgmt.
Only added code to populate the document no field of approval entry table.
LOCAL PopulateApprovalEntryArgument(RecRef:RecordRef;WorkflowStepInstance: Record “Workflow Step Instance”;VARApprovalEntryArgument: Record “Approval Entry”)
Code added in PopulateApprovalEntryArgument function within the Case Statement:

- Now create a new Codeunit 50000 to add new functions
I have added the following global C/AL variables in the new codeunit.


Workflow Management is Codeunit 1501. Approval Entry is Record 454. SMTP Mail is codeunit 400.
- Add the following functions in the new Codeunit.


The properties of each function are as follows:
a. RunWorkflowOnSendJobTMforApprovalCode


Code written in this function is:
b. RunWorkflowOnSendJobTMforApproval


Code added in this function is:

c. RunWorkflowOnApproveApprovalRequestforJobTM


Code added in this function is:
d. RunWorkflowOnApproveApprovalRequestForJobTMCode


Code added in this function is:

e. AddWorkflowEventsToLibrary


Code added in this function is:

f. AddWorkflowTableRelationsToLibrary


Code added in this function is:
g. RunWorkflowOnRejectApprovalRequestforJobTM


Code added in this function is:
h. RunWorkflowOnRejectApprovalRequestforJobTMCode


Code added in this function is:
i. RunWorkflowOnDelegateApprovalRequestForJobTM


Code added in this function is:
j. RunWorkflowOnDelegateApprovalRequestForJobTMCode


The code written in this function is:

k. OnSendJobTMforApproval which is a Publisher function with Event Type ‘Integration’
C/AL Locals are:


l. IsJobTMApprovalsWorkflowEnabled


Code added in this function is:

m. CheckJobTMApprovalsWorkflowEnabled


The code added in this function is:

n. SendJobForApprovalFunction
C/AL Locals are:

Properties of the function are:


This is a subscriber function and will get triggered when the ‘Send Jobs For Approval’ action is clicked which is present in Job Card.
The code written in the function is:
o. To access the record from the approval request, you need to modify Codeunit 700 Page Management.
Create a function in C/AL globals
Add the following code in this function

Now in GetConditionsCarPageID() function, add the following:

In my next blog, I have given the remaining setups and steps required to be done in the Dynamics NAV client to create customized workflows. You can click on the link below for my next blog:
Thanks for reading my blog!

Like
Report
*This post is locked for comments