How To Create Work Flow In D-365 F&O ?
What is workflow?
A workflow in the dynamics 365 apps is a way that automate business processes without a user interaction. People usually use workflow processes to commence automation that doesn’t require any user involvement.
1.Create a Work Flow Project : ::WRE_EmployeeWorkFlowStatus;
2.Create a Base Enum:WRE_WorkFlowStatus
Next Add The Elements In BaseEnum-Below Attachment
3.Create a New Table -Regular Table -WRE+EmployeeLeaveTable;
4.Create a Fields in Table Like Below Image
6.Create A Method override Can SubmitToWorkFlow method of This Table
public boolean canSubmitToWorkflow(str _workflowType = '')
{
boolean ret;
ret = super(_workflowType);
if(this.WRE_WorkFlowStatus != WRE_WorkFlowStatus::Approved)
{
ret = true;
}
else
{
ret =false;
}
return ret;
}
7.Create A New Method Update WorkFlowStatus
}
8.Create a WorkFlow Custom Form New Form WRE_EmployeeLeaveForm
Set allowEdit Property of enum control in the Grid to No.
9.Create a Display Menu Iteam In Form10.Enter the create form name in the object property and set the label of the menu item,
13.Build the project with database synchronization.
14.Add work flow category “CustomWorkflowCategory”
Below classes and action menu items will automatically be created.
Change the label of workflow type submit action menu item.
Change the label of workflow type cancel action menu item
Add the below code in submit manager class.
/// <summary>
/// The EmployeeLeaveWorkflowTypeEventHandler workflow event handler.
/// </summary>
public class EmployeeLeaveWorkflowTypeEventHandler implements WorkflowCanceledEventHandler,
WorkflowCompletedEventHandler,
WorkflowStartedEventHandler
{
public void started(WorkflowEventArgs _workflowEventArgs)
{
WRE_EmployeeLeave::WRE_EmployeeLeave(_workflowEventArgs.parmWorkflowContext().parmRecId(),WRE_WorkFlowStatus::None);
// TODO: Write code to execute once the workflow is started.
}
public void canceled(WorkflowEventArgs _workflowEventArgs)
{
WRE_EmployeeLeave::WRE_EmployeeLeave(_workflowEventArgs.parmWorkflowContext().parmRecId(),WRE_WorkFlowStatus::Cancelled);
// TODO: Write code to execute once the workflow is canceled.
}
public void completed(WorkflowEventArgs _workflowEventArgs)
{
WRE_EmployeeLeave::WRE_EmployeeLeave(_workflowEventArgs.parmWorkflowContext().parmRecId(),WRE_WorkFlowStatus::Approved);
// TODO: Write code to execute once the workflow is completed.
}
}
Build the project with database synchronization.
Now add the workflow approval “CustomWorkflowApproval”
A window will appear.
- Select workflow document (It’s the class which was created automatically it returns the query).
- Enter field group of the custom table.
- Enter display menu item name.
Some classes and action menus created automatically.
Enter workflow approval name in the Element Name property and also provide a name.
Change the label of workflow type.
Now build the project with database synchronization.
Open the form in d365 browser, see there is no workflow button enable. So, we need to configure the custom workflow in the attached module like we setup it in the Accounts Receivable module.
Go to Accounts Receivable module > Setup > Accounts receivable workflows. Click on the Accounts receivable workflows
Click on New button.
Select custom workflow type from the list (It’s the label of workflow type)
A new window will appear click on “Run” button.
A new form will open, enter email and password
If you are not logged in with admin account the below error will appear.
If you are logged in with admin account the below window will appear; Design the workflow according to your need.
Click on “Basic settings” and add placeholder.
Navigate to assignments and add select “User” option.
Click on “User” button and add user there.
Now click on “Basic Settings” Button under assignment window and provide placeholders.
Now drag workflow approval in the workflow window
Click on start and drag the connector (Arrow) to the workflow approval function.
Scroll the bar you will find end function.
Click on workflow approval and drag the connector (Arrow) to the end function.
Click “Save and close” button.
Click “OK” button and another form will open, click on “Activate” button there to activate the workflow.
Go back and now open the form again and you will see the workflow button visible there.
No comments:
Post a Comment