Part 10 - Business Process Flow (BPF) in Dynamics 365 CRM


Business Process Flow:

==> Business Process Flow (BPF) is a visual guide that helps users follow a structured process when working with records in Dynamics 365 CRM.

==> It also ensures that required steps are completed before progressing to the next stage in a process.


key components of a Business Process Flow:

  • Stages: High-level phases of the process (e.g., Qualify, Develop, Propose, Close).
  • Steps: Fields that users must fill out at each stage.
  • Branching Conditions: Logic to control how users move between stages.
  • Actions: Can trigger workflows, business rules, or JavaScript.


==> We can also use BPF on Multiple Entity(Tables)

Example: Lead → Opportunity → Quote).

==> By default, a BPF runs at the client-side (form level). However, if you set the scope to Entity, it runs on both client and server side.

==> We can also use Power Automate to trigger actions based on stage changes in a BPF.

Example: When a sales opportunity reaches the "Propose" stage, send an automated email to the customer.


How do security roles impact BPFs:

  • BPFs can be assigned to specific security roles.
  • Users without access to a BPF won't see it on the record.
  • Different roles can have different BPFs for the same entity.


==> when a record does not meet BPF requirements, Users cannot move to the next stage until all required fields are filled.

==> An Entity can have multiple Business Process Flows, but only one can be active at a time. Users can switch BPFs manually if they have the right permissions.


==> The execution order of BPF, Business Rules, and JavaScript is

Business Rules execute first (client-side logic).

BPF executes next (guides the process).

JavaScript runs last (custom scripts can override BPF and Business Rules).


==> To debug issues in a Business Process Flow?

Use Developer Tools (F12 in Chrome/Edge) to check errors.

Check the Audit Log to see who made changes.

Use Power Automate flow logs if automation is involved.


==> BPF can interact with Plugins and these Plugins can be triggered on stage transitions.

Example: When a record moves to "Propose," a Plugin can validate pricing rules before allowing the transition.


Example: Sales Opportunity Management in D365 CRM

How BPF interact with Business Rule, JavaScript, Power Automate and Plugins.

We will create a Business Process Flow (BPF) for managing Sales Opportunities, integrating:

Business Rules (Client-Side Validation)

JavaScript (Custom Form Logic)

Workflows/Power Automate (Automatic Notifications)

Plugins (Server-Side Validation & Automation)


Step 1: Create a Business Process Flow

==> Go to Power AppsDataverseTables

==> Select Opportunity → Click Business Process FlowsNew BPF

==> Name: Sales Opportunity Process

==> Select Entity = Opportunity

==> Click Create


Article content

==> Save & Validate the BPF

==> Activate it

Now, the BPF is active on the Opportunity entity.


Step 2: Add Business Rules to BPF

Requirement: Auto-hide/show the "Manager Approval" field in the Propose stage.

==> Go to Power AppsDataverseTables → Select Opportunity

==> Click Business RulesNew Business Rule

==> Condition:

If "Estimated Revenue" > 50,000 → Show "Manager Approval"

Else → Hide "Manager Approval"

==> Action:

Add Show Field action for "Manager Approval".

Add Hide Field action for "Manager Approval".

==> Save & Activate

Now, "Manager Approval" is only shown when Estimated Revenue > $50,000.


Step 3: Add JavaScript for Custom Form Logic

Requirement: Show a warning message if the user forgets to select "Competitor Analysis" in the Develop stage.

==> Go to Power AppsDataverseTables → Select Opportunity

==> Click FormsMain Form

==> Add a Web Resource (JavaScript File)


function checkCompetitorAnalysis(executionContext) {

var formContext = executionContext.getFormContext();

var competitorAnalysis = formContext.getAttribute("competitor_analysis").getValue();

if (!competitorAnalysis) {

alert("Please complete Competitor Analysis before moving to the next stage.");

}

}


==> Attach this function to the OnChange event of the "Stage" field.

==> Save & Publish

Now, a warning appears if users forget to fill in Competitor Analysis.


Step 4: Add Power Automate flow

Requirement: Send an email when an Opportunity reaches the "Propose" stage.

==> Go to Power AutomateCreate Flow

==> Select Dataverse ConnectorWhen a BPF Stage Changes

==> Condition:

If Current Stage = Propose

==> Action:

Send an email notification to the Sales Manager.

Now, an email is sent automatically when an opportunity reaches "Propose".


Step 5: Add a Plugin for Server-Side Validation

Requirement: Prevent Opportunity Closure if Estimated Revenue is below $10,000.

==> Open Visual StudioCreate New Project

==> Select Class Library (.NET Framework)

==> Install Microsoft.CrmSdk.CoreAssemblies

C# Plugin Code - Providing only logic

if (context.MessageName.ToLower() == "update")

{

Entity opportunity = (Entity)context.InputParameters["Target"];

if (opportunity.Contains("estimatedvalue"))

{

decimal estimatedRevenue = ((Money)opportunity["estimatedvalue"]).Value;

if (estimatedRevenue < 10000)

{

throw new InvalidPluginExecutionException("Estimated Revenue must be at least $10,000 to close the Opportunity.");

==> Compile & Register Plugin using Plugin Registration Tool

==> Attach to Update Event on Opportunity

Now, users cannot close an Opportunity if Estimated Revenue < $10,000.



To view or add a comment, sign in

Others also viewed

Explore topics