Get logged in user’s Security roles names in UCI

Here is sample code to get security roles name of logged in user.

function GetLoggedInUserSecurityRoleNames() {
 // Get Logged In User Context
 var userSettings = Xrm.Utility.getGlobalContext().userSettings;
 // Get Logged In User Security Roles
 var loggedInUsersecurityRolesGuidArray = userSettings.securityRoles;
 var totalSecurityRolesArray = new Array();
 var rolesOutputText = "";

if (loggedInUsersecurityRolesGuidArray.length > 0) {
 Xrm.WebApi.retrieveMultipleRecords("roles", "?$select=name,roleid").then(
 function success(result) {
 if (result.entities.length > 0) {
 // Push Role Names and Role Ids to Array
 for (var rolesCount = 0; rolesCount < result.entities.length; rolesCount++) {
 totalSecurityRolesArray.push({ RoleName: result.entities[rolesCount].name, RoleId: result.entities[rolesCount].roleid });
 }

rolesOutputText = userSettings.userName + " has the below Security Roles\n------------------------------------\n";

// Compare the User Security Roles with Total Security Roles
 for (var userSecurityRolesCounter = 0; userSecurityRolesCounter < loggedInUsersecurityRolesGuidArray.length; userSecurityRolesCounter++) {
 for (var totalsecurityRolesCounter = 0; totalsecurityRolesCounter < totalSecurityRolesArray.length; totalsecurityRolesCounter++) {
 if (totalSecurityRolesArray[totalsecurityRolesCounter].RoleId.toLowerCase() == loggedInUsersecurityRolesGuidArray[userSecurityRolesCounter].toLowerCase()) {
 rolesOutputText += totalSecurityRolesArray[totalsecurityRolesCounter].RoleName + "\n";
 break;
 }
 }
 }
 }

// Show User Roles
 Xrm.Utility.alertDialog(rolesOutputText, null);
 },
 function (error) {
 // Show error
 Xrm.Utility.alertDialog(error.message, null);
 });
 }
}

Duplicate workflows in advanced find – CRM 365

While searching for the process in the Advanced Find of my MS Dynamics CRM 365 environment, I noticed that several “duplicates” of the process appeared. Although they had the same name, some of them were in Draft Mode and two were Active. One curious thing that I saw was few processes are same logic and steps, also, whenever I did a change in one of my Active workflow/business rule, the other was replicating the change. This made me had a hard time trying to figure out what was happening, specially because after searching the duplicates in the Default solution to delete them, only one appeared.

Continue reading “Duplicate workflows in advanced find – CRM 365”

Xrm.WebApi.online.execute (Client API reference) in MSD 365

Xrm.WebApi.online.execute(request).then(successCallback, errorCallback); can be used for CURD operations, also to execute workflow and action. In the above syntax ‘request’ will be a object which can have all information of the operation. The details of the request can be found here in more depth. Here is some details ..

Continue reading “Xrm.WebApi.online.execute (Client API reference) in MSD 365”

Activate-Deactivate Plugins/Process with code

while deploying our customisation to target environment many times we need disable/deactivate plugins and or process. Manually, its straight forward but what about when you are working with DevOps or you cannot touch target environment. In such environment, we need to handle it with code. So for that here are the steps …

Continue reading “Activate-Deactivate Plugins/Process with code”

System jobs in Dynamics

For DevOps, we have to handle each and everything from code behind and in automated way. Thus, wrote code to create manage System jobs to delete records every night in Dynamics. Here are the main points from my understanding ..

The BulkDeleteRequest message will create a bulk delete job that will be automatically executed on a specified interval for a specified set of data.  The job will be executed by the CRM Asynchronous service.

Continue reading “System jobs in Dynamics”

Pass parameter to RDL

Sometime we need to send parameter dynamically to SSRS report, to achieve it below JS function will help … here key thing is “&p:”, whatever next to this one will be considered as parameter, e.g. “&p:parameterName=parameterValue”. You can pass more than one parameters too.

Continue reading “Pass parameter to RDL”

Reports in MSD 365

To create SSRS report for MSD 365, we need SQL Server Data Tool, its part of Visual studio itself. To create report follow the below steps ..

Continue reading “Reports in MSD 365”

Microsoft Learn- New DLP

Microsoft launched a new learning portal called ‘Microsoft Learn‘. You will find here study materials for MSD 365 apps and all. Earlier DLP (Dynamics Learning Portal) was doing same thing but it was closed portal, not open for everyone.

There are plenty of courses but few are ..

Learning for Field Service:

Learning for Power Apps:

Learning for MSD 365 Portals:

Learning for Customer Engagement:

Learning for Customer Service:

Learning for Marketing:

Learning Sales:

That’s it for now!! Thanks!

JavaScript Changes – Dynamics 365 9.0

This blog is re-blogged, thanks to Sachin Bansal!!

JavaScript Model Changes ||    New Client APIs     ||     Deprecated Client APIs

J1

There are significant changes made to Client APIs in Dynamics 365 version 9.0 release. Table below lists four main changes happened in this release:

Continue reading “JavaScript Changes – Dynamics 365 9.0”

Auto-Mapper

AutoMapper is a simple library built to getting rid of code that mapped one object to another. explore more about Auto-mapper here.

Add it from NuGet packages manager or execute below command

PM> Install-Package AutoMapper

here is sample code to use it…

Continue reading “Auto-Mapper”