Switch-Case in a Flow | Power Automate

Some of the common operations / decision making one wants to perform in terms of programming is definitely switch-case!

Here’s how you can do it in power automate

Scenario

To keep things simple, I will simply reflect the name of the OptionSet value in a variable in Flow –

    1. Here’s my OptionSet called Account Type with values Customer [1], Vendor [2] & Partner [3]
      optionSet

 

    1. My Flow will be called on update of Account record’s Account Type field change
      updateOfAccountType

 

    1. I’m simply using a variable to store the value of the selection made on the field.
      initVariable

 

Using Switch

Now, let’s get to the important part –

    1. If you search for Switch under Control, you’ll see as below
      switchControl

 

    1. This will first ask you what the Switch should be on, in this case, it’s the Account Type value to be selected from the dynamics values
      accountTypeChosen

 

    1. Now, I can start entering the Cases one by one as shown below and setting the variable I created above. For value in Equals 1, I’ll set variable as Customer
      firstCase&Default
      case1DetClicking on the + [Plus] sign in between Case and Default will let you add more cases.
      addCase

 

    1. Finally, once all the cases are entered, the Flow will start looking something like this from a hawk-eye-view with the Default case appearing in the end.
      hawkEye

 

Working

Let’s look at how Switch-Case would work –

    1. I updated the Account Type field with Vendor
      d365Updated

 

    1. Switch on the Account Type Value (selected from Dynamic Values) will reflect the value of 2
      2Selected

 

    1. And Case 2 will execute simply reflecting what is stored in the variable. Rest of the cases will not run
      result

 

Pretty Easy! Hope this helps!

Advertisement

Dynamics 365 PSA v2 to v3 Upgrade failed? Here’s what to do.

This is a little tricky upgrade from PSA v2 to PSA v3. I’m sure by this time of the year, most of you must have upgraded and this post by me comes a little late than it should.

Here’s my experience and what help from Microsoft Support I needed to complete the Upgrade successfully.

So usually, this is what you expect when you initiate the upgrade process. You go to the Instance Picker from Dynamics 365 Admin Center.
upgradeButton

And you can see that you are on PSA v2.4.x version and the New version available is 3.10.x. When you kick off, it starts running
upgradeInProgress
But, it fails like this.
installFailed

Let’s take a stab at it!

I usually prefer to go with the old school classic Instance Picker, if you want to have a quick access to it, check this post – D365 Admin Center: Instance Picker Link

Solution Health Hub

Note: Please be aware that below mentioned steps that involve Project Service & Project Service Upgrade Rule Set can only be provisioned by Microsoft Support and we need to create a Support Request with Microsoft for them to provide this Rule Set. These comes in a Managed Solution Microsoft Support installs from their end into your environment.

  1. Assuming Microsoft Support has enabled this Rule Set for your organization, you can go to Solution Health Hub
    createNewAnalysisJob
  2. Then, select either Project Service or Project Service Upgrade
    ruleSet
  3. It will automatically run asynchronously as and when you create it. It should display results in a few moments.
    failedValidation
    In this case, my failures were that Resource Requirement records didn’t have Hours & Resources were not filled in. Some Project Tasks didn’t have Project attached to them which resulted in corrupted PSA data according to the Rule Set and hence, the upgrade fails.
  4. Now, in my case, I cleaned this data manually. Post that, I created another Analysis Job to ensure that there are no more failures.
    passedRuleSet
    Also, there’s another Rule that isn’t mentioned here but is a reason for failure. That is – Project Name (msdyn_Subject) should NOT be Blank. Use Advanced Find to find these records and correct manually.  Please ensure this manually as it won’t appear here. 
  5. Now, there’s a workflow called as Update User Work History. It should have shown 3.3 or higher in the version to select, unfortunately, this will come once the upgrade fails 1 time.
    oldWF
  6. Now, you are all set to kick off Upgrade Once again. It will fail due to the incorrect workflow mentioned above in #5.
    installFailed
  7. Now, you can go back and check that workflow, it should have the correct version appearing (due to the partial upgrade that happened in #6 above, which eventually failed)
    updateUserWorkHours
    Set this to 3.3 and Activate the workflow again.
  8. Now, trigger the Update to PSA v3 one more time. And this time it should go through correctly.
    installedPlease note, due to constant upgrades in the platform/PSA, there could still be some undetected issues which could result in failure. Hence, I tried to put what I experienced in general.

    Post this, also ensure that all SDK Message Process Steps and related Workflows related to PSA are enabled.

In case you are also looking to find out about dependencies about failed Solution Upgrades, you can check this post too – Check Managed Solution failures in Solution History in D365 CE

Hope this helps!

Dynamics 365 Solutions’ New Experience in Power Apps, Solution Checker and more

If you’ve recently noticed Settings > Solutions area in Dynamics 365, you’ll see a notification that this has been moved
alertNotification

And you’ll be redirected to Solutions Area in Power Apps –
newArea

Solution Checker

Solution Checker is a helpful feature where it runs a validation of components in the Solution itself –

  1. If you see for your custom Solutions, if you haven’t ever Run a check on the solution, the status will be Hasn’t been run
    checkNotRun
    I’ll zoom it below –
    statusZoomed
  2. Now, you can run the Solution Checker against your entity to find potential issues and add/remove component that matter.
    selectRun
  3. Once the Run starts, it will show the status of Running… for the solution as well as in the Power App ribbon.
    running
  4. Once the run is complete, you can see the time stamp it completed on and also View/Download the results –
    runComplete
    viewResults
  5. You can see the results as below –
    sampleResult1
    So basically, it’ll show what best practices should be followed in order for the Solution to be meeting highest standards of configurations and customization.
  6. Another example from another solution is this –
    removeDebug
  7. Or something like – under Upgrade Readiness category
    upgradeReadiness

    Full details can be found here on Microsoft’s official document – https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/use-powerapps-checker#review-the-solution-checker-report

Solution Export Versioning

Now, every time you export a solution, by default it is set to Managed unlike Unmanaged in the Classic UI.

Also, notice the Version number is auto-incremented to x.x.x.1
defaultBehavior

And in further exports, the version keeps on auto-incrementing
incremented

Hope this helps!!

Setting Retry Policy for an HTTP request in a Flow | Power Automate

Often times, There could be an issue where your HTTP request isn’t hitting well. So, to overcome this, you might want your Flow to Retry after a certain duration and for some number of times.

You want to setup a Retry policy for the same. Here’s how you do it!

Setting Retry Policy

Follow this to setup a Retry Policy of your Flow

  1. Locate your HTTP step and navigate to Settings
    openSettings

  2. Once you’re in Settings pane, scroll below and look for Retry Policy.
    retryPolicyLocation

  3. Default type is set by default, if you expand it, you can select what should be the Retry Type. In  this example, I’ve set to Fixed Interval for simplicity
    Default is set to 4 retries at an exponential interval. (Exponential increment type is a little confusing to explain, you can check this post as users discuss how exponential time increments work – )fixedInterval
  4. In Fixed Interval type, I’ve set number of retry count to be 3 and duration between each retry should be 30 seconds (represented in ISO-8601 format)
    sampleRetrySet
  5. With that, the policy is set. And the HTTP request step will try for 3 times at the interval of 30 seconds each.

 

If you want to test using some HTTP request, you can sample HTTP requests from here – https://httpstat.us/

How it works

Look for Failed Runs to see the result –

  1. Open a Failed Run where you know HTTP request could have failed
    openFailedRun
  2. Now, look for your HTTP request where you set the policy on. Expand the same.
    openHTTPCallThatFailed
  3. Upon expanding, you can see that there were 3 retries and it failed due to a timeout i.e. 408
    failedRetries
  4. You can also check on the right hand side of the page which says that the total duration of all these retries were 1 min 30 seconds
    totalFixedTime

If you observe the Flow Runs, you can find the the Flow did consistently try to run at an interval for the number of times specified.

In case you’re looking for more Flow/Power Automate related posts, check below –

  1. Make HTTP request from Flow in Power Automate
  2. Using Parse JSON to read individual List Records in Flow|Power Automate
  3. Selecting (Current) in Environment in Power Automate CDS connector and why it matters
  4. Retrieve only active Dynamics 365 CE licensed Users in CDS connector in Power Automate
  5. Secure Input/Output in Power Automate Run History
  6. Approval Process using Power Automate
  7. Create a To-Do List Item of Important Outlook Emails using Power Automate
  8. RSS notifications to your phone using Power Automate
  9. Enable Flow button on D365 Ribbon
  10. Button Flow in Power Automate to replicate a Quick Create Form in D365 CE

Hope this helps!!

Debug Ribbon button customization using Command Checker in Dynamics 365 CE Unified Interface

Developers, it’s a little irksome to keep struggling with issues around making your ribbon buttons work correctly during the development phase.

At times, you wonder why your button didn’t show up on the form although you had set everything up correctly. Or even for out-of-box button, that didn’t show?

Scenario

In this example, I’ll find out by my Project Service Quote record doesn’t have a Activate Quote button on the ribbon.

noActivationButton
We can use Command Checker to find out why.

 

Enable Command Checker

Remember, this only works in the Unified Interface and not on the classic UI.

Command Checker is a developer feature to identify how a certain ribbon button has or has not rendered on your form/view. So let’s begin –

Add this command to the end of the Entity form page URL: &flags=FCB.CommandChecker=true&ribbondebug=true

Add make it look like something like below –
https://<ORG_NAME&gt;.crm<REGION>.dynamics.com/main.aspx?appid=7fbb5a25-b903-ea11-a816-000d3a58f769&pagetype=entityrecord&etn=account&id=aaa19cdd-88df-e311-b8e5-6c3be5a8b200&flags=FCB.CommandChecker=true&ribbondebug=true

 

Command Checker

Form Command Checker

  1. Now, if you navigate to the ellipses on the ribbon, check that Command Checker has now appeared.
    formCommandChecked
  2. A Command Checker Window will appear as below. Navigate to the button you are having issue on.
    baseWindow
  3. Then, click on Command Properties as shown above to see what didn’t pass through. And as shown below, we could see that one of the conditions in Enable Rule didn’t get through and hence, the button didn’t show up on the ribbon.
    commandCheckerWindowIn case you are also looking at how to hide out-of-the-box ribbon buttons, check this – Hide Custom Ribbon Button [Easy Way] – Ribbon Workbench

Global Command Checker

And with that, you must have also observed the Command Checker on the Navigation Ribbon bar as well.
globalCommandChecker
And it opens up as below –
globalCommand

 

Some other Ribbon Workbench related posts –

  1. Show Ribbon button only on record selection in Dynamics CRM
  2. Enable Flow button on D365 Ribbon
  3. [SOLVED] Navigating URL from Ribbon’s custom button in Dynamics for Phones app
  4. Fix Ribbon icons on the Unified Interface in D365 CE
  5. Create a New Record button for Activity Type entity using Ribbon Workbench: D365
  6. D365 Ribbon Button shortcut to open a Document in SharePoint Online

Hope this helps! Happy 365ing!

 

Using Parse JSON to read individual List Records in Flow|Power Automate

This is a scenario I came across when I was using Common Data Service connector [not Common Data Service (Current Environment)] connector to read Opportunities tied to an Account.

Example

In this scenario, I wanted to retrieve the Opportunities tied to an Account. So, my filter query was _parentaccountid_value(‘ACCOUNT_IDENTIFIER’)

Here’s my Flow starts. I want to read Opportunities that are tied to my Account in context –

baseQuery

Flow Inside a solution vs. Outside a Solution

Inside a Solution

Now, when I had this Flow inside a solution, the result didn’t have a body and instead just gave me Status Reason value as below –

missingData

Outside a Solution

Whereas, outside the Solution, I was able to get the array of Objects i.e. Opportunity data in the Body in the Output itself.
outsideSolutionResult

So, what can we do about the Flow which is used inside a Solution and you want to actually see what was the output? You may or may not require to see the records (depending on your implementation)

But let’s say you want to see what was returned, let’s just parse these results as is using Parse JSON to see what we got.

Use Parse JSON from Data Operation

Another way to read what you’re retrieving is using Parse JSON Data Operation.

  1. Search Parse JSON and you’ll see the result in Data Operation type of Actions as shown below –useParseJSON
  2. Now, you have to apply this to Current item from the retrieved List records in Apply to each operation. In case you don’t have the schema or not sure what to put it in. Simply use {} in Schema field. This will just pass through as is.
    applyParseJSON

Checking Result

Now, let’s test using the above and see if we can get the results

  1. Now, you can actually see the Inputs and Output of Parse JSON which is basically the same. This is useful if you want to visually see what’s going on through your Flow.
    visibleResult

But, if you don’t want to see what’s being passed through when in Production? You can Secure Input/Output in Power Automate Run History

Hope this helps you!!

Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE

This is one of the most useful common scenarios where you have to approach a Global Administrator every time to Approve Emails. Even when you want to create a few Queues or test Mailboxes on a non-production environment.

I would recommend this to be used only on Sandbox instance and let Production instance have this layer of approval of Global Administrators, but then it depends what you want to have. 🙂

 

Approve Email

Every time, you want to enable a mailbox for Server Side Synchronization, you are asked to Approve Email.
(If you want to enable Server Side Sync for enabling D365 App For Outlook, check this post Summarizing D365 App For Outlook Setup in 3 steps with Exchange Online mailbox)

emailWontProcess

And even if you try to Test & Enable the mailbox, you’ll see the error as This mailbox is disabled for email processing.
tryTest

And you get the error as IncomingEmailS2SApprovalNeeded. Let’s look at how even System Administrators who aren’t Global Admins can enable Mailboxes.

 

 

Disable Approve Email for Mailboxes & Queues

So, if you want to not have each mailbox need an Approval from Global Administrator, go to Settings in site map > Administration > System Settings > Email tab
settingsArea
In the above screenshot, you select which of the mailboxes or queues or both, you want to allow to process emails without approval. Now, I want to only disable the need for approval for Queues and keep the users as is.
disableForQueue

But doing so myself, gives me the following error
cantDisable

That’s because, to disable this, you’ll need a Global Administrator once. Once they disable this, if you have the appropriate rights to Test & Enable Mailbox, you can directly Test & Enable a mailbox even though the error message is still displayed on the Mailbox after disabling this feature.
success
The mailbox for the Queue is now active.

In case you are also looking to create a Support Queue for your organization, you can check this post Create a support Queue in D365 CE.

Hope this helps!!

Make HTTP request from Flow in Power Automate

One of the most common asks I’ve come across lately is people asking whether or not, we can make external HTTP requests using Flow in Power Automate. Well, yes! Let’s quickly take a look at how you can do that.

Scenario

To keep the example really simple, I have an API that I can use to call to get weather information. (By the way, you’ll find MSN Weather connector in Power Automate too)
So, the API I’m using to test the call is OpenWeatherMap. Their API is really easy to understand for this example.

Note: You can create your account here and you’ll get an API key which you can use.

  1. Now, Let’s say I have the API key and I’m ready to consume their API.
    You can have your Flow start any which way you want, I’m just running it on schedule –
    Select HTTP in the search and select the HTTP trigger
    selectAction
  2. Now, I can fill in the data required to make the HTTP call. In my example, the API is expecting Query String, so I’m passing the values in Queries as needed. It could be different in your case.
    I’m select GET method since we are trying to retrieve data by calling the API
    getSelected

    And then go on to write the rest of the request.
    sampleRequest
    Let’s say, if you’re required to pass headers to a POST request with Body, you can do that as well.

  3. And I’m capturing the response in a variable in Flow to further use it. I’ve chosen to store it in an Object type of variable.
    captureResponseEasy!

Making HTTP Request

Now, let’s test it. I made a sample request and I’ve received the response as below –
I’ll open my response part –
openResponse

Check this, in case you want to also secure the data your receive – Secure Input/Output in Power Automate Run History

And I’ve received the data successfully! Hope this gets you started in making HTTP calls.

Pass data to HTML Web Resource using browser’s sessionStorage in Dynamics 365 CE

If you’re using Xrm.Navigation.openWebResource(webResourceName, windowOptions, data), you probably are already using ‘data’ to the HTML Web Resource you are opening.

Here, I’m using an alternate method. I use JSON to send my data since it is widely preferred and used. Basically, I’ll Stringify my JSON object and add it to session storage, then – retrieve it from sessionStorage and Parse is back to object.

 

Opening Web Resource

Now, in my example, I’m not passing my data in the ‘data’ parameter provided by Xrm.Navigation.openWebResource(), instead I’m putting it in JSON.

  1. Let’s say, somewhere in my code, I want to send out a JSON to the HTML Web Resource which will open in a new window.
    So, instead of passing ‘data’ to Xrm.Navigation.openWebResource(), I’ll simply do the following –
    First, create a JSON object of what I want to send as data.
    Then, I’ll use sessionStorage.setItem(“<key>”, JSONObject); to add it to the sessionStorage and then open the WebResource using Xrm.Navigation.openWebResource()
    storedInSession

Reading from Session Storage

Reading from sessionStorage is as easy as putting data into it. Just the reverse –

  1. Assuming you are familiar with HTML and JS references, make sure you have correctly referenced the JS file you want to use with your HTML. Provide the name of the Web Resource in which you have your JS code.
    fileReferrenced
  2. Once the HTML document is loaded (I prefer using JQuery here to put things into document), you can read the same using sessionStorage.getItem(“<Key>”);

    And then, JSON.parse() the object retrieved from sessionStorage.
    retrived

  3. Also, if you look at the Application tab in Dev Tools of your browser, you can check for Session Storage info.
    You’ll find the Item you stored to the session
    inApplication

That way, you can use sessionStorage to keep your data in the browser session if you don’t have any other concerns or reasons not to use sessionStorage.

 

Hope this helps!!