Sample Code – Dynamics 365 Web API / Organization Service


Refer appropriate connection string as required with CrmServiceClient- 

https://docs.microsoft.com/en-us/powerapps/developer/data-platform/xrm-tooling/use-connection-strings-xrm-tooling-connect#connection-string-examples

the connection string parameters

Replace Office 365 authentication with OAuth

https://docs.microsoft.com/en-us/powerapps/developer/data-platform/authenticate-office365-deprecation

Advertisements

Recent Posts –

Environment Variable referencing Azure Key Vault secrets (Dataverse / Power Platform)

Check out the below articles – https://docs.microsoft.com/en-us/power-apps/maker/data-platform/environmentvariables#use-azure-key-vault-secrets-preview Within plugin – https://itmustbecode.com/azure-key-vault-secrets-in-dataverse/ Within Power Automate – https://www.msautomate.com/2022/06/16/azure-keyvault-and-power-automate/ https://powerapps.microsoft.com/en-us/blog/how-to-use-environment-variables-with-akv-secrets-in-the-ci-cd-pipeline-when-deploying-applications/ https://blog.yannickreekmans.be/environment-variable-secrets-azure-key-vault-improvement/

How to – Add users to the Queue – using Manage NN relationships XrmToolBox Plugin and AddPrincipalToQueueRequest (Dynamics 365)

Recently we implemented Unified Routing for one of our projects, and as part of testing we were supposed to add multiple users to different queues (advanced queues … Continue reading “How to – Add users to the Queue – using Manage NN relationships XrmToolBox Plugin and AddPrincipalToQueueRequest (Dynamics 365)”

Loading…

Something went wrong. Please refresh the page and/or try again.

Dynamics 365 Sales mobile app (preview)


The new Dynamics 365 Sales mobile app (preview), has been introduced specifically for the field sellers who need quick access and intuitive management of the customer information on the go while travelling / meeting the customers.

Check other posts on 2020 Release Wave 2

To enable the App, navigate to Advanced Settings from the Sales Hub and then to Administration > System Settings > Mobile Client tab
We also need to enable Relevance search on the environment for the mobile app’s search to work.

For iOS

https://go.microsoft.com/fwlink/p/?linkid=2151689

For Android

https://go.microsoft.com/fwlink/p/?linkid=2152008

After installation open the app and sign in

From the list of apps, select the App to be used. Here we clicked on the Sales Hub app.

Below is the home page of the app.

The home page provides quick access to recent contacts and recent records along with reminders and insights.

More on Assistant –

https://docs.microsoft.com/en-us/dynamics365/ai/sales/assistant

The + option allows for the quick creation of Note and Contact records.

The more options allow access to the navigate to other part of the apps – dashboard and the other entities.

Search suggestions provide results while we are typing and grouping of search results to quickly find the information needed.

Other sub grid and form tab improvements in the app –

https://nishantrana.me/2020/09/28/sub-grid-and-form-tabs-improvements-in-power-apps-mobile-app/

The meetings option shows the calendar view and the meetings that are scheduled in the outlook.

We cannot create meetings from the Sales Mobile app.

Get all the details here –

Overview of the Dynamics 365 Sales mobile app

Blog posts on 2021 Release Wave 1 – Dynamics 365

Hope it helps..

 

Recent Posts – 

Loading…

Something went wrong. Please refresh the page and/or try again.

How to – Consume Dynamics 365 Web API using MSAL.NET


Sharing a sample code to consume Dynamics 365 Web API using MSAL.NET

Create a console application and add the following NuGet Package

  • Microsoft.Identity.Client

More on Microsoft identity platform

https://docs.microsoft.com/en-us/azure/active-directory/develop/

We are using ConfidentialClientApplicationBuilder create method.

https://docs.microsoft.com/en-gb/azure/active-directory/develop/msal-net-initializing-client-applications

The sample code –

using Microsoft.Identity.Client;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace CrmAppMSAL
{
class Program
{
static async Task Main(string[] args)
{

string clientId = "fc34502a-74db-4977-8c83-***********";
string secret = "5~mByJeQ8dDO2LZP_H_J2**********";
string[] scope = new string[] { "https://orgname.crm15.dynamics.com/.default" };
string webAPI = "https://[org].crm15.dynamics.com//api/data/v9.0/leads";
string authority = "https://login.microsoftonline.com/7bc93881-0733-48ab-baa1-ee3ed7717633";

var clientApp = ConfidentialClientApplicationBuilder.Create(clientId: clientId)
.WithClientSecret(clientSecret: secret)
.WithAuthority(new Uri(authority))
.Build();

try
{
AuthenticationResult authResult = await clientApp.AcquireTokenForClient(scope).ExecuteAsync();

var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");
httpClient.DefaultRequestHeaders.Add("OData-Version", "4.0");
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);

httpClient.BaseAddress = new Uri(webAPI);

var response = httpClient.GetAsync("WhoAmI").Result;

if (response.IsSuccessStatusCode)
{
var userDetails = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(userDetails);
Console.WriteLine(authResult.AccessToken);
Console.WriteLine(authResult.ExpiresOn);
Console.ReadLine();
}

}
catch (Exception ex)
{
string errorMessage = ex.Message;
}
}
}
}

Result –

Reference –

https://medium.com/capgemini-microsoft-team/access-tokens-for-dynamics-365-using-microsoft-authentication-library-2b16c9f794b

https://nishantrana.me/2021/01/06/sample-code-dynamics-365-web-api-organization-service/

Hope it helps..

Advertisements

Fixed – 401 Unauthorized error while calling Dynamics 365 Web API


We were recently getting the below error while trying to call Dynamics 365 Web API through Postman.

“401 Unauthorized”

It turned out that we were using the incorrect Token.

To generate the correct token,

For OAuth 2.0 token endpoint (v1) Version 1

  • We need to specify resource with Dynamics 365 URL.


For OAuth 2.0 token endpoint (v2) Version 2

  • We need to specify scope with
    Dynamics 365 URL followed by .default instead of a resource.

The correct token results in the successful call to the Web API

References –

https://matthijs.hoekstraonline.net/2020/04/27/v1-and-v2-identity-and-access-tokens-with-azure-active-directory/

https://crmchap.co.uk/generating-oauth2-v2-0-endpoint-tokens-for-dynamics-365-the-common-data-service/

Hope it helps..

Advertisements

How to – Check user’s access to a record – upcoming feature in Dynamics 365


Was going through the Model-Driven Apps documentation and found the below article

https://docs.microsoft.com/en-us/powerapps/user/access-checker

It talks about a Check access button on the command bar of a record which will list down all the rights/access/privileges on that particular record.

And also how the user has got those accesses, through security roles directly assigned or through the team the user belongs.

We can also check the access of the other users as well through user lookup.

More on Access in Dynamics 365

Hope it helps..

Advertisements
Advertisements

Power Platform for Admins connector (preview) in Power Automate


The Power Platform for Admins connector (preview)

let’s us perform following Actions


The connector allows us to access the Business Applications Platform (BAP) API.

Below is the example of the Create Environment action, followed by Create CDS Database.

Here we are creating a trial environment in Asia region followed by a CDS database in it with base language – Hindi and currency code as INR

Let us run the flow and see the results

In Power Platform admin center can see the environment created along with the database specified.

All the key URL(s) for Power Platform Admin

Get all the details below –

Power Platform for Admins (Preview)

Power Apps and Power Automate Administration and Governance – Tools and Labs

Hope it helps..

%d bloggers like this: