Retrieve only active Dynamics 365 CE licensed Users in CDS connector in Power Automate

Let’s say you have a requirement where you want to work only on Dynamics 365 and you are using Office 365 Get User Profile action to retrieve all users.

In this example, I have some Dynamics 365 Customer Engagement licenses assigned to uers. And I want to retrieve only the Active D365 Users in my Common Data Service Connector.

Here’s how I do it –

Retrieve Users with Filter Condition

Now, the best thing you could do is identify what is the userlicensetype field of other Dynamics 365 users you might have retrieved in your previous executions.

licenseTypeFilter

I’ve used the query userlicensetype eq 6 to query for Active D365 users

If you want to retrieve Users who have been Disabled, you can check by using userlicensetype eq -1

Note: You’ll need to check the respective values for other users who have licenses like Team Member or Sales Professional. Since I haven’t tried those, I don’t have their exact number codes. Best way is to identify a user whose licence configuration you are looking for and look for their userlicensetype field value in Flow.

Result

This gave me only those users who have D365 Customer Engagement License assigned to them
4retrieved

And if I look at my O365 Portal, I can see that 4 users have the Dynamics 365 Customer Engagement License
D365Licensed

There are even more ways you can use to identify for different licenses used. I recommend it’s good practice to retrieved only those users which are needed for your operation.

If you’re also looking to secure the Input/Output data in Flow, refer this Secure Input/Output in Power Automate Run History

Hope this helps!

Advertisement

Refresh button missing on Roll-Up fields in D365 UCI? Quick Tip.

As we are transitioning to the Unified Interface, some visual cues are a little misplaced or say, hidden.

If your Roll-up field on the Classic UI appeared like this where you could simply click on refresh and update the Roll-up field

classicRefresh

It doesn’t seem to be the case in terms of UCI-
missinginUCI

It’s Hidden!

So, simply click on the Calculator icon –
clickToReveal
And the Recalculate button will be revealed which updates the value
recalculate
And results into the below in my case –
updated
Note: Toggling the calculator icon will reveal/hide the button.

Hope this quick tip helps!!

 

AutoNumber field in CDS | PowerApps

The most desired feature is ability to create/customize your own auto-number field. ANd CDS let’s your do just that!

I remember the good old days when I had to write a plugin to function for AutoNumber which used to configuration from a supposedly separate Configuration entity and it scary to maintain the code and entity. But this solves all that with so much ease!
allRecords

Create an AutoNumber field in CDS

  1. Now, you can start by creating a field in CDS’ Solutions > [YourSolution]> [YourEntity]
    createNew
  2. Then, under Accounts, you can see that you can actually create an Autonumber. This is not available in Classic UI.
    Also, please note that you’ll need to keep this field Not Required and Locked (on the form) in order to function.
    underTextGroup
  3. Give it  a suitable name and then you have 3 options to format your auto-number field.
    2TypesOfAutonumber

    String Prefixed number

    You’ll need to define the Prefix, Min Digits, Seed value
    preview

    Date prefixed number

    With Date prefixed, you’ll need to define Date Format, Min Digits of Seed Value
    dateFieldPreview

    Custom

    With custom, you can define the Format. Refer Microsoft’s Documentation for the same – AutoNumberFormat options
    customPreview

Save and Publish as you usually would and place your field on the form you want.

Working

I used String method to design my AutoNumber field. Let’s see how it looks –
Once I save the record, the Auto-number will be filled in.
fieldWorking

If you happen to delete any records already created in the sequence, the auto-number functionality will continue counting upward and not fill out previous backlogs/last deleted auto-number records.

Hope this helps!

Call Azure Function from Dynamics 365 CRM using Webhooks

This is a vast topic to cover in a blog. But I wanted to write from a bird-eye’s view of how this will pan out in an implementation where you perform a certain operation in Dynamics 365 CRM and an Azure Function is called to perform further operations.

This post is written keeping in mind fair knowledge of Azure Functions, Storage accounts and subscriptions in mind.

I’ll try to keep the article short, so stay with me! 🙂

Create a Function App in Azure

  1. Let’s say you have created a Function App in Azure already and want to connect to Dynamics 365 CRM. Click on the big + New Function button in the screenshot below
    resourceOverview_LI
  2. Now, since I want to keep Visual Studio as my driver for coding and deployment, I’ll create a new Project in Visual Studio of type Azure Functions and click Next
    newProj
  3. On the next page, I’ll give a relevant name and hit Create.
    createProjectButton
  4. Since we will be using Webhooks to connect to the Azure Function, the trigger chosen here is Http Trigger.Make sure you select Framework because Microsoft.Xrm.Sdk assemblies don’t work on .NET Code, but on .NETFramework only.And then you should take care of what your Storage Account and Authorization should be – Finally click Create once done.
    frameWorkSelected
  5. The Project will open with 1 .cs file, so make sure you name your plugin initially –
    accountPluginGetsInApp
  6. It’ll take a while to create the Project. Once created, go to the Portal on Azure and click on the Get Publish Profile
    getPublishProf_LI
    It will be downloaded on the computer. Keep it so that you can import it on the Project in Visual Studio to use for Direct Publish.
    downloadedProfile
  7. Now, right click and chose Publish to make your first push as is so that the Account Function gets pushed to Azure App.
    firstPublish
  8. Then, click on Import and import the Publish Profile settings downloaded in step #5 above –
    selectImport
  9. Once imported, you’ll be taken here – simply Publish once.
    quickPublish
  10. Once Publish is successful, check in the Azure App in Portal, the Function should appear.
    accountPluginGetsInApp

 

Modifying code to read Webhook Call from Dynamics 365

  1. To keep it simple, I’m simply reading the context and then, you can flourish your App further to make it work as required.
    captureContextSo, I’m only reading the request into a String and logging it so that we can see it in the logs in the Azure Function app.
  2. You can use RemoteExecutionContext class to actually get all the contextual information into the Function app and then use it further. See below –
    remotecontext
  3. Once ready with your code, Publish it.

Now, let’s Register the Webhook and call the app.

If you’re also looking for remote debugging, this is a great article-Remote Debugging Azure Functions V2 “The breakpoint will not currently be hit. No symbols have been loaded for this document”

Register a Webhook in Plugin Registration Tool

Coming to Dynamics 365 CRM side of things, you can register a Webhook that will trigger on Account Name update to fire off the AccountPlugin Function App created above –

  1. In Plugin Registration Tool, register a new Webhook
    registerWebHook
  2. Enter Webhook Details. Select Authentication type as WebhookKey
    enterWebhookDetails
  3. Now, to get the key, go to the Function App in portal, and look </> Get function URL link.
    getKeyandURL
  4. Copy the same and paste in Notepad, separate the code part from the main URL
    selectCopy
    separateCodePart
  5. Paste the URL part in Endpoint URL and key in the Value field. Click Save.
    registerWebHookWIthDetails
  6. Now, add a Step to the Webhook. For this example, I’ve chosen update of Account‘s Account Name field
    addStepregisterStepInWebhook
    And Register it.

Execution

  1. The purpose was to simply ready Dynamics 365 Account record upon modification of the Account Name
    recordChange
    And save the record.
  2. In a minute or so, the Log will be generated (only the logs take a little longer to generate)
    triggered
    And thus, we are able to send data / or rather, call Azure Function and process Dynamics 365 CRM data using Webhooks.

Some other Azure related post you might like to look at – Use Azure App Passwords for MFA enabled D365 authentication from Console App

Hope this was helpful! Tried my best to keep it basic and short as possible. I’m sure you all will explore way beyond and develop awesome implementations!

Show Loading Screen in Dynamics 365 using Client API reference

Suppose, you want to show a loading/waiting screen to let people know there’s some heavy processing going on in the back-end and they shouldn’t navigate away to do anything else with the record, you can use loading screen by using showProgressIndicator() and closeProgressIndicatory() methods.

Xrm.Utility methods

There are 2 methods are documented in the Xrm.Utility of Microsoft Docs that you can use to achieve this. Microsoft reference here.

In this scenario, let’s say you want to show the Loading page while your Action is being performed by the JavaScript code.

  1. You can place the Xrm.Utility.showProgressIndicator(message); before you begin your code to invoke an action and place Xrm.Utility.closeProgressIndicator(); in your success and failure messages.
    codePositions

Execution

Whenever your JS code will call the action, the progress message will be displayed on the screen as below  –

In Classic UI
clasicMessage

In Unified Interface –
UCIMessage

And once the process is complete, the Xrm.Utility.closeProgressIndicator will remove the message as below and bring back the form you were working on –

messageOver

Side Note: If you are using action calling from JS using invokeProcessAction, as of the day of this post – This doesn’t work well and results in action not supported error on the UCI – invokeProcessAction does not work in UCI

Hope this helps!

Global Notification in Dynamics 365 Unified Interface App [Preview]

Here’s a great feature to add a warning/error notification which is scoped globally unlike setFormNotification() which is commonly used and remains within a form itself.

Xrm.App.addGlobalNotification(notificationObject).then(success, error); serves this purpose. Let’s see how –

Disclaimer: Please be aware this is a preview feature yet and I’ll update on this post once this is out of preview.

This is only available for the Unified Interface.

Scenario

Let’s say you have opened an Account form and you want to warn the user in case they are working remotely with someone and might have their screen shared. You want to show a message like this –
globalNotif

And even if they navigate away from the form, it will remain on the screen since it’s scope is global.
navigatedOtherPlaces

Or, user can chose to close it manually which appears at the end of the strip on top-right corner.
canCloseIt

You can also optionally add a button and make it navigate to another URL in case you want to share more info with the users (In my example, I redirected to https://www.microsoft.com/en-in/) –
learnMoreButton

Example

Xrm.App has 2 methods to do the needful –

Xrm.App.addGlobalNotification(notificationObject).then(success, error) & Xrm.App.clearGlobalNotification(notificationObject).then(success, error)

In my scenario, I want to trigger the warning message as soon as the user wanders into one of the Account records. So, in my case, I’ve registered the method onLoad of the Account form itself.
Here’s the code in my JS file for the same –

Some notes before we proceed with the code –

  1. type in the notification object is supported as 2 at the moment and no other types are supported.
  2. The levels are as below
    1. Success
    2. Error
    3. Warning
    4. Information

account = {
globalNotification: function () {

var learnMoreAction =
{
actionLabel: “Learn more”,
eventHandler: function () {
Xrm.Navigation.openUrl(“https://microsoft.com&#8221;);
}
}
var notificationObj =
{
type: 2,
level: 3, //warning
message: “Please make sure you are not sharing your screen!”,
showCloseButton: true,
action: learnMoreAction
}

Xrm.App.addGlobalNotification(notificationObj).then(
function success(result) {
console.log(“Notification created with ID: ” + result);

// More code here
},
function (error) {
console.log(error.message);
// handle error here
}
);
}

};

I’ve registered the Function as account.globalNotification. You can directly use globalNotification is you are writing function directly as function globalNotification() {}

fnAdded

This notification remains App-wide unless closed by closed by a user of closed using clearGlobalNotification method as mentioned by Microsoft.

Source documentation by Microsoft is here – Xrm.App

Since we are transitioning into Unified Interface, here are some other related posts that you may like looking at –

  1. D365 Quick Tip: Why BPF wouldn’t appear in D365 Unified Interface?
  2. Fix Ribbon icons on the Unified Interface in D365 CE
  3. Change the Unified Interface App Icons
  4. Unified Interface App URLs – 3 different ways

Hope this helps!!

Create a To-Do List Item of Important Outlook Emails using Power Automate

Since Power Automate is so powerful that you can creatively use it to improve your productivity at work. Here’s an example of how you can utilize a scenario where you need a quick checklist to make sure you respond all important emails for the day.

Power Automate

  1. You’ll need to create an Automated Power Automate and select the trigger as Office 365 Outlook. Select ‘When a new email arrived (V3)’ from the same and make sure you only select the High Importance marked emails
    selectOnlyHighImp
  2. Next step, create a To-Do Item. Select the List you have created. In my case, I created a separate list called ‘Respond Important Emails’
    toDoList
    And the step to configure the To-Do List item should be like this –
    addToDoStep
    In the above picture, I’ve made sure I select the correct List I want to create a To-Do in.

    And to give myself some time, I’ve added a reminder time of 2 hours from the time this Flow/Power Automate will run i.e. when the email will come in –
    add2Hours

How it works

Now, when an Important email will arrive in my Inbox as below –
actualEmail

Power Automate will create a To-Do in my created List
newItemAdded

And it will look like this –
reminderIn2Hours
Also, the reminder is set to remind me 2 hours post the time the To-Do item was created. Just in case I’m into something else, I’d set myself a reminder.

Hope this helps! And you can use your creativity to improve your productivity!

Show Ribbon button only on record selection in Dynamics CRM

One of the most common asks is to show ribbon buttons to only be shown when at least 1 record in Dynamics 365 ribbon button are selected.
buttonShow

Here’s how you can do it –

Enable Rule in Ribbon Workbench

This can be achieved using Enable Rule for the button you wish to show on selection using Ribbon Workbench.

Let’s say your button ‘Promote’ (in this case) is on the Main View of the Account entity. You can add the following Enable Rule to the command –
enableRuleBound

And in the actual Enable Rule, you can select the SelectionCountRule to make this happen. You can set the minimum value to 1 so that it appears when at least 1 record is selected.
acutalEnableRule

Result

Now, if you see – By default, the button is hidden –
buttonHidden

Now, as you can see, only when at least 1 record from the view is selected, the button is visible.
buttonShow

In case you are looking to hide a custom button, check this post – Hide Custom Ribbon Button [Easy Way] – Ribbon Workbench

Hope this helps!!

RSS notifications to your phone using Power Automate

RSS is powerful and taming it wisely really helps! 🙂 Here’s an example where I used it to get a notification whenever a new blog was posted by Microsoft in their Dynamics 365 Blog page. It is my attempt to stay updated on the latest posts so that I don’t miss anything.

Scenario

  1. Let’s say, for example, this is the website I want to read RSS feeds from. So click on the RSS icon – https://cloudblogs.microsoft.com/dynamics365/
    feedIconOnWebsite
  2. Copy the URL from the Feed page
    copyURL

Build your Power Automate

  1. Start by building your Power Automate, you can select the Trigger as RSS.
    createFlow
  2. Paste the URL copied from your RSS source above, and then add a step to send a Notification. You can have anything here, it’s up to your use case of what you want to do with the Power Automate further on.
    powerAutomate

Getting RSS Feeds on Phone using Power Automate

Now, once all this is set, here’s how I’ll get notifications on the phone once I have Power Automate setup and authenticated to the correct environment of Power Automate.

  1. Whenever there’s a new blog posted on https://cloudblogs.microsoft.com/dynamics365/, I get a Power Automate notification on the phone like this
    phoneNotif
  2. And when you click on it, you’ll see what has been posted, it will open up in the Power Automate app
    openPA
  3. And when you click on the link, it will take you to the actual blog Post
    actualPost

Hope this helps you in your application or use case! Cheers!!