BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate

Here’s an update to the Common Data Service (Current Environment) connector in Power Automate

Remember, this is available only in Common Data Service (Current Environment) connector i.e. you’ll need to create you Flow inside a Solution in Power Automate
undefined

Flow Step

Now, you can call your Flow from a Business Process Flow, which existed for some time. But now, it’s available as a trigger in the Common Data Service (Current Environment)
undefined

Flow & BPF Setup

  1. Now, my Flow is kept simple to illustrate what has been triggered. The first step simple is run When a flow step is executed.
    It starts with a simple Instant Flow like template if you want to have an additional input
    undefined
    And then you can use these in the context further. But I’ll keep it simple assuming you are familiar with trigger inputs.
  2. Then, you get the details that you can use from the trigger.
    undefined
  3. And I’m simply passing on the values over to an email so that I can read it. You application could be anything. Typically, it could be a complex business process in a Flow to trigger when a Flow Step is triggered.
    undefined
  4. Now, in my Business Process Flow Step, I’ve added a Flow Step (Preview), mind that this is still in Preview as of writing this post.
    undefined
  5. And select the Flow I’ve intended for this.
    undefined

Running the Flow

Now, here’s how it goes –

  1. I’ve called the Flow from the Flow Step
    undefined
  2. It’ll ask for confirmation of the Flow in a window
    undefined
  3. Once all the permissions are set, depending on what’s needed in the Flow, you’ll be asked for a confirmation
    undefined
  4. Once completed, you can check in Flow Runs about what happened to the execution of the Flow
    undefined


Results

So here are some results I composed from the data of the BPF itself-
undefined

And that’s it!

Here are some more Power Automate / Flow posts you might want to look at:

  1. Pause a Flow using Delay and Delay Until | Power Automate
  2. Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
  3. Text Functions in a Flow | Power Automate
  4. Loop through array of objects in a Flow & Create records in CDS | Power Automate
  5. Get Count of records retrieved in CDS connector in a Flow | Power Automate
  6. Number Formatting in a Flow | Power Automate
  7. Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
  8. Switch-Case in a Flow | Power Automate
  9. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  10. Make HTTP request from Flow in Power Automate

Hope this helps!!

Advertisement

Execute an Action from a Business Process Flow

One of the easiest and useful feature of a Business Process Flow is being able to Implement and Action right from a Business Process Flow just with a click of a button.

Here’s how you do it.

Let’s say you have an Action that you want to trigger that the Account was Approved for some sort and you want to alert the Stakeholders. You can have this functionality in your Action and call the Action from the BPF itself.

Action

  1. Let’s say your Action has some logic as below which you want to execute when you trigger Action on BPF
    actionLogic
  2. Make sure your Action is marked as below for it to be enabled for adding in a BPF
    enableForBPF

Once this is set, let’s move to the BPF part.

Business Process Flow

  1. In a BPF, since you have enabled your Action to be added to BPF, you’ll be able to add it as below.
    addActionStep
  2. In the Properties, look for your Action Process and select it and click Apply.
    actionFound
  3. Make sure you’ve clicked on Apply.
    apply

Now, you’re all set. Let’s see how it works.

Execution

Now, this is how you’ll see your Action on the BPF on the record,

executeButton

When you click on Execute, it will mention (if you don’t have any Input parameters) that there are not parameters and ask for Confirmation
noInputParameters

Once you confirm, this is how it will show while executing –
executing

 

If there’s any failure, it will show as below
executionFailure

 

And success like this
success

Simply click and the Action will execute!

Hope this helps!!

Sending Image from Canvas PowerApps to SharePoint Document Library using Flows

One of the most common requirements is to upload images to SharePoint using PowerApps. From my learning from various sources, I’ll try to “demystify” my explanation to send/upload an image to SharePoint Document Library using Flows on my Canvas PowerApp.

Ingredients

Assuming you have the following things already  in place in PowerApps as well as in SharePoint

  1. PowerApps’ Camera/Image control and a Submit button. In my case, the image above is a camera so that I capture the image I want and the image below is the Image control to show me what I clicked.
    powerApp
  2. A SharePoint Document Library to record, say, Incidents.
    spDocLibrary
  3. We will get to the Submit button on the PowerApp once we create our Flow.

Flow

Let’s create a Flow to pick the Image from your PowerApp, convert it to binary and send it to the SharePoint Document Folder location called Incidents.

  1. Since we want to trigger the Flow from the PowerApps itself, we will select the trigger of the Flow as ‘From PowerApps’ and hit Create
    createFlow
  2. Once your Flow is ready, leave the first step of PowerApps because that’s the trigger. Add Step to create a SharePoint file and fill in the details of the Document Library you have created.
    createSPFile
  3. Fill in the FileContent as above. You’ll need this to be converted in the intermediate step after this.
  4. Now, you’ll need to add an additional step in between PowerApps and the Create SP File step as below. It will be a Compose action.
    addAction
  5. In Compose action, under Expression, select dataUriToBinary expression and make sure you open the bracket as well.
    dataUriToBinary
    toolTipHidden
  6. Now, go back to the Dynamic Content section and select the CreateFile_FileContent to complete the formula.
    fileContentAvailable
    completedFormula
  7. Click OK on the screenshot above and the formula should be set.
  8. Now, replace the File Content section to take in the Output of the Compose step.
    outputRecorded
  9. Save your Flow and your complete Flow should look like this.
    CompleteFlow
  10. I’m naming my Flow as ‘IncidentFlow’ so that I can identify it.
    incidentFlow

Adding the Flow to Submit button

Going back to the PowerApp, let’s Run this Flow on the selection of the Submit button and pass the image.

  1. Now, select the Submit button, and on the Formula bar, add the Flow you created, I named it IncidentRun. Select the same so that the Formula comes as IncidentRun.Run( for you to pass on the image.
    Now, pass the latest image on the collection i.e. the same image which is being displayed in the image control below.

    runFlowFormula

 

Running the App

I just ran the app on the desktop itself, you could do it from your phone too!
So I clicked on the Camera when I was ready, the image appeared in the image control and I that was what I wanted to upload. So I clicked on Submit button.
hittingSubmit

The flow was successful
FlowSuccessful

And my image was in SharePoint too!
imageUploaded

I know it is a lengthy post but I tried to summarize as much as possible. Make sure you have a way to uniquely name each file or else, the same file will be overridden.

Thank you!

 

BPF Process Stage Name not populating on records in D365 v9 [Deprecated] and workaround.

At times, users are unaware of the deprecation announced for D365 v9 version earlier in 2018 or simply, they’re not aware whether to look for deprecation announcements. One of the most common instances I’ve come across lately are when people complaining about the Process Stage Name entity not updating post the v9 update.

missingData

Deprecated Feature – Process

So when you try to add these columns in you entities’ views, you’ll see that StageID (Process Stage) is now shown as Deprecated.

deprecatedField

Read More About It Here

Here’s the Microsoft link where this is stated and other deprecations for upcoming D365 versions:

https://docs.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/important-changes-coming#legacy-process-related-attributes-in-entities-are-deprecated

Alternative/Workaround

But, it is important that you also have a workaround at hand to keep the data up to date. Here’s a quick workaround to get the Stage Name.

  1. Create a custom Single Line of Text field on the entity that you need the Stage name on. In this case, Opportunity entity.
  2. Create a Real-time Workflow on the BPF entity itself. In this case, it was the Opportunity Sales Process BPF’s entity called as ‘Opportunity Sales Process’.
    wfCreate
  3. The workflow will be triggered when the Process is Applied and then Active Stage field is updated on the BPF.
    wfBody
  4. And in the Step, it will only update the Opportunity’s custom field to the Active Stage.
    wfUpdateStep
  5. That way, you can have the Stage Name data in your custom field and use that instead.
    populatedDate

Hope this helps! 🙂

Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

While working with BPF fields using JavaScript, there can be instances where you might want to keep the field locked in a certain stage but unlocked in another stage. And using Xrm.Page.getControl(controlName) or for v9 – getFormContext.getControl(controlName) should differentiate between the 2 fields?

Let’s see what we need to do here.

Scenario

  1. Let’s say I want the users to enter Customer Need data in Develop Stage.
    unlockedField
  2. But, just view what data is present in Propose Stage shown below, not modify it. (I’ve just renamed the field to Summarize Customer Need instead)
    lockedFields

JavaScript Usage to access the Control

  1. Now, since the Summarize Customer Need field is the second time, using getFormContext.getControl(“header_process_customerneed”) will be fetched to disable the first field only i.e. Customer Need in Develop stage.
    unlockedField
  2. To access Summarize Customer Need, you need to append “_1” to the control name for the second occurrence. And _2 and so on for further occurrences.
    Here’s the sample code which I used to access Summarize Customer Need to access the second occurrence of the field and use setDisabled(true) to lock it –
    code3. And that way, you’ll be able to access Summarize Customer Need control and do your desired operation (like even make it hidden or visible depending on your scenario) –
    lockedFields
    Hope this helps!

What happens when you force fields on BPF to be required programatically or using Business Rule

I had a requirement where I needed to make certain fields on BPF as required.

So, I tried accessing the control using Xrm.Page.getControl(“header_process_description”) and then getAttribute().setRequiredLevel(“required”) on it would serve my purpose. But actually, not!

To set perspective, the code runs and make the field required too. But there’s a catch!

Required fields on the BPF are supposed to throw an error when you are trying to move to the next stage without filling in the required fields.

But, using the code I’m talking about above (sample shown below), will force you to save the form entirely. Let alone moving the stages further.

jsCode

That when ‘How Did You Hear About Us?’ field has Employee Referral as value, make Purchase Process field required.

empoyeeReferalSet

Field is on the BPF

fieldOnBPF

But prompts me to save the form
promptToSave

 

Workaround

The easiest workaround to this is using the conditional branching of your business process flow –

You can use conditional branching of the BPF itself – You can replicate the same stage twice, one having your required field and other having that same field as optional.

bpfBranching

However, limitations I found with this approach is –

  1. I couldn’t use the same for the first stage of the BPF –
    limitation1
  2. The condition had to be from the previous stage itself
    limitation2

P.S. Business Rules isn’t a solution as well. Also, I tried to inverse the logic by first making the field required in the BPF itself and then trying to make it not required using code. That doesn’t work either.

Hope this gives an idea. Let me know if you have other suggestions! 😊