Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : BgrGSOgOkQEVgu8ks3Fwgr
Dynamics 365 Community / Blogs / Tina Menezes Blog / Procedure to create a custo...

Procedure to create a customized Workflow in Dynamics NAV by creating new workflow events – Part 1

Tina Menezes Profile Picture Tina Menezes 2,582

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:

  1. In table 167 i.e. Job table, I have created a new field ‘Approval Status’.                         image001
  2. The properties of the above field is as follows:

image003

  1. 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:

image004

  1. Now create a new Codeunit 50000 to add new functions

I have added the following global C/AL variables in the new codeunit.

image006image008

Workflow Management is Codeunit 1501. Approval Entry is Record 454. SMTP Mail is codeunit 400.

  1. Add the following functions in the new Codeunit.

image010image012

The properties of each function are as follows:

a. RunWorkflowOnSendJobTMforApprovalCode

image013

image015

Code written in this function is:image016b. RunWorkflowOnSendJobTMforApproval

image017image019

Code added in this function is:

image021

c. RunWorkflowOnApproveApprovalRequestforJobTM

image023image025

Code added in this function is:image027

d. RunWorkflowOnApproveApprovalRequestForJobTMCode

image029image031

Code added in this function is:

image033

e. AddWorkflowEventsToLibrary

image035image037

Code added in this function is:

image039

f. AddWorkflowTableRelationsToLibrary

image041image043

Code added in this function is:image045

g.  RunWorkflowOnRejectApprovalRequestforJobTM

image047image049

Code added in this function is:image051

h. RunWorkflowOnRejectApprovalRequestforJobTMCode

image053image055

Code added in this function is:image057

i. RunWorkflowOnDelegateApprovalRequestForJobTM

image058image060

Code added in this function is:

image062 j. RunWorkflowOnDelegateApprovalRequestForJobTMCode

image064

image066

The code written in this function is:

image068

k. OnSendJobTMforApproval which is a Publisher function with Event Type ‘Integration’

C/AL Locals are:image069image071

image073

l. IsJobTMApprovalsWorkflowEnabled

image075image077

Code added in this function is:

image079

m. CheckJobTMApprovalsWorkflowEnabled

image081image083

The code added in this function is:

image084

n. SendJobForApprovalFunction

C/AL Locals are:

image086

Properties of the function are:

image088image090

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:image091

o. To access the record from the approval request, you need to modify Codeunit 700 Page Management.

Create a function in C/AL globalsimage093

Add the following code in this function

image095

Now in GetConditionsCarPageID()  function, add the following:

image096

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:

https://tinamenezes.wordpress.com/2017/11/25/procedure-to-create-a-customized-workflow-in-dynamics-nav-by-creating-new-workflow-events-part-2/

Thanks for reading my blog!



This was originally posted here.

Comments

*This post is locked for comments