User Security Manager – My first XrmToolBox Plugin


Nishant Rana's Weblog

Being one of the biggest fan and the most frequent daily user of XrmToolBox, always had this wish to write a plugin for it.

Thanks to Prashant Maurya  (a dear friend and ex-Microsoft Employee) for making this wish come true. (Who played the major role in developing it).

The tool is called – User Security Manager.

The Plugin make it easy for the administrators to manage all the security related aspects of the system users. The tool also gives 360-degree information of the user in correspondence to business unit, security roles and teams.

In our current project we had around 180 users using the system divided into more than 50 business units, which involved frequent update of their business unit, changes in the security roles assigned, update in team assignment and also during testing we had to assign the same BU and roles to the test users…

View original post 472 more words

How to Create a, “No Code”, Lead Capture Solution


Donna Edwards

Today I would like to share with you how easy it is to get started using PowerApps and the Common Data Service.  For this example, I created a “Lead Entry” PowerApp for use by Sales to quickly enter a new Lead from any supported device.  The lead will be entered into my company’s Dynamics 365 online application and then moved to the Common Data Service using Microsoft Flow.

This article assumes that you have given your user record the required licenses in your Office 365 account (PowerApps & Flow) and that you have logged into the PowerApps admin area and set the appropriate privileges on the environment.  Here are a couple of articles to help with those steps if you have not completed them.

PowerApp Q & A

CDS Environment Overview

Create CDS database 

This article will walk you through the creation of a Common Data Service database, a PowerApp…

View original post 1,053 more words

Issue with Data Export Service Add-ons


In one of requirement, we wanted to use CRM Data for reporting purpose but due to some limitation with FetchXml (like N-N relationship) we were unable to get desire data so we decided to use Data Export Service Add-ons to push into Azure and make use of data for reporting purpose.

When we tried to install/Enable the Data Export Service from Dynamics Marketplace, the add-on installed successfully without any error but when we tried browse Data Export Service(Settings -> Data Export), it was showing blank page and Data Export Profile page was not displaying at all in IE 11 as below.

We raised ticket to Microsoft and they suggested to add below URL in IE trusted site list and once we added these sites in trusted site, we were able to see Data Export Profile page(Settings->Data Export) as shown below.
https://*.azure.net
https://*.crm.dynamics.com
https://*.microsoftonline.com
https://*.windows.net

Note: In Google Chrome , It was working fine even without adding above URLs in trusted sites.

Hope this will help someone.

Configure Dynamics 365 and Azure Service Bus Integration


As we know, we can connect Dynamics 365 with Azure platform by coupling Dynamics 365 event execution pipeline to the Microsoft Azure Service Bus. Once configured, this connection allows data that’s been processed as current Dynamics 365 operation to be posted to the service. Microsoft Azure Service Bus solutions that are “Dynamics-365 aware” can listen for and read the Dynamics 365 data from the service bus.There are many ways to establish a contract between Dynamics 365 and an Azure solution as below.

  • Queue
  • One-way
  • Two-way
  • Rest
  • Topic
  • Event Hub

In this post, I will use “Queue” contract where a listener doesn’t have to be actively listening for messages on the endpoint.
Let’s implement a basic scenario – When a record is created in CRM then pass the execution context to queue and then prepare a application to read and display the entity information.

Lets first configure Azure to create a Queue listener using Azure Portal(https://portal.azure.com).

  1. Create a Service Bus by click on “Add” button.

    2. Enter mandatory fields as below.

3. Create a Queue in newly created Service Bus(mcstaging in my case)

4. Create SAS Policy for Authorization and copy the Primary Connection String which is required during end point registration in CRM

Now let’s create service endpoint in CRM using plugin registration tool.
Login into plugin registration tool and click on Register ->Register New Service End Point as below


Copy the primary connection string form  step 4 and click on “Next”

All information will be populated automatically and then click on “Save”.
Now, need to register a step for this endpoint(In my case, custom entity Enquiry(mc_feedback)  on create message).


Now create a enquiry record in CRM, once you create a record in CRM a system job will be created and message will be passed to azure queue created earlier.

You can see one message in queue as below


Now, how to read the message from Queue. Lets create a console application to read the message from Queue.
Here the connection string will be the same which we had specified in the plugin registration tool. The message body is of type RemoteExecutionContext.


Output

 

Debug WCF Restful service (POST/GET) – Part 2


There are many way to debug WCF/Cloud service hosted in Azure and you can refer the below tutorial but I prefer to debug the service old and easy way by deploying the service in local IIS then publish to Azure.

https://docs.microsoft.com/en-us/azure/vs-azure-tools-debug-cloud-services-virtual-machines

https://docs.microsoft.com/en-us/azure/vs-azure-tools-debugging-cloud-services-overview

In Part 1, I explain how to create and deploy WCF Restful service in Azure.

https://arvindcsit.blog/crm-and-azure-integration/

I will use the same existing code and will add another POST method to explain debugging.

I am going to create one POST method which takes User Name and Password as request body and return predefined token.

So I added below code in Part 1 source code.

Contract: ICRMService.cs

Under ServiceContract

[OperationContract]
[WebInvoke(Method = “POST”,
UriTemplate = “/getauth”,
ResponseFormat = WebMessageFormat.Json)]
CRMTokenResponse GetCRMToken(CRMTokenRequest tokenReqeust);

DataContract
[DataContract]
public class CRMTokenResponse
{
public CRMTokenResponse()
{
this.Token = “”;
this.Error = “”;
}
[DataMember(IsRequired = false)]
public string Token { get; set; }
[DataMember(IsRequired = false)]
public string Error { get; set; }
}
[DataContract]
public class CRMTokenRequest
{
[DataMember]
public string Username { get; set; }
[DataMember]
public string Password { get; set; }
}
CRMService.svc.cs
public CRMTokenResponse GetCRMToken(CRMTokenRequest tokenRequest)
{
CRMTokenResponse resp = new CRMTokenResponse();
if (tokenRequest != null)
{
string userName = WebConfigurationManager.AppSettings[“CRM.Username”];
string password = WebConfigurationManager.AppSettings[“CRM.Password”];
string tokenId = WebConfigurationManager.AppSettings[“CRM.Token”];
if (tokenRequest.Username == null || tokenRequest.Password == null)
{
resp.Error = “Enter UserName and Password”;
return resp;
}
if (tokenRequest.Username.Equals(userName) && tokenRequest.Password.Equals(password))
{
resp.Token = tokenId;
}
else
{
resp.Error = “Invalid Username & Password”;
}
}
else
{
resp.Error = “Request is Null”;
}
return resp;
} 

Web.config

Add these three lines under <appSettings></appSettings> tag.
<add key=”CRM.Username” value=”Arvind” />
<add key=”CRM.Password” value=”Singh” />
<add key=”CRM.Token” value=”8178746c24b9f5544d259f2a38d7c1a785bc70a2″ />

We are done with code changes, make sure you build the project in Debug mode and deploy in local IIS.

Browse the service and make sure the service is running without any error. I will use PostMan to hit and debug the service.

Set the breakpoint and attached to W3WP process. Select the Content Type and Request Body as below.

Then Click “Send” and cursor will stop at breakpoint as shown below.

you can see the token value while debugging as below

Finally, you get output in output window of PostMan as below.

Similarly, you can debug it for GET method. Once your service is working fine, you can publish your service to Azure using steps mentioned in PART 1 (https://arvindcsit.blog/crm-and-azure-integration/)

Hope this helps you.

 

 

 

 

Check open activity related case using oData query


Sharing below code which returns some value using oData query. This function will check if there is any open activity related to Incident entity.

function CheckOpenActivity() {

var Id = parent.Xrm.Page.data.entity.getId();

var IncidentId = Id.substring(1, 37);

//Retrieve dynamically the organization’s server url

var serverUrl = document.location.protocol + “//” + document.location.host + “/” + Xrm.Page.context.getOrgUniqueName();

var ODATA_ENDPOINT = “/xrmservices/2011/OrganizationData.svc”;

var ODATA_EntityCollection = “/IncidentSet?$select=IncidentId,Incident_ActivityPointers/ActivityId,Incident_ActivityPointers/StateCode&$expand=Incident_ActivityPointers”;

var ODATA_Filter1 = “&$filter=IncidentId eq guid'” + IncidentId + “‘”;

var oDataRequestUrl = serverUrl + ODATA_ENDPOINT + ODATA_EntityCollection + ODATA_Filter1;

var result = syncODataCall(oDataRequestUrl);

var isOpenActivity = ProcessReturnedEntities(result);

if (isOpenActivity)
alert(‘The Case has open Activity’);
else
alert(‘The Case has not any open Activity’);

}

// function to make synchronous oData call

function syncODataCall(odataSelect) {

var request = new XMLHttpRequest();

request.open(“GET”, odataSelect, false);

request.setRequestHeader(“Accept”, “application/json”);

request.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);

request.send();

var objJQuery = jQuery.parseJSON(request.responseText);

return objJQuery.d

}

function ProcessReturnedEntities(d) {

var hasRelated = false;

if (d.results[0] != null) {

var activities = d.results[0].Incident_ActivityPointers;

if (activities != null) {

if (activities.results.length > 0) {

$.each(activities.results, function (index) {

if (activities.results[index].StateCode.Value == ‘0’) {

hasRelated = true;
return hasRelated;

}
});

} else {
hasRelated = false;
return hasRelated;
}

} else {
hasRelated = false;
return hasRelated;
}
}
return hasRelated;
}

 

Hope this help you.

Get Internet Explorer (IE) Version


Hi,
We faced some CRM Issue based IE Version i.e some of the functionality was working fine in IE 8.0 and IE 9.0 but not working on IE 10.0 or later.. I had written the below function to detect the IE version and chage the logic accordingly.

function MSIEVersion() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf(“MSIE “)
var rv = ua.indexOf(“rv:”);
var compatible = ua.indexOf(“compatible”);
var ieVersion;

// If IE Version <= 10 and compatiable mode return version number
if ((msie > 0) && (rv == -1) && (compatible > 0))
{
ieVersion = parseInt(ua.substring(msie + 4, ua.indexOf(“.”, msie)));
if (ieVersion == 10)
{
ieVersion = ieVersion + 1;
}
return ieVersion;
}
// If IE Version <= 10 and not in compatiable mode return version number
if ((msie > 0) && (rv == -1) && (compatible == -1))
{
ieVersion = parseInt(ua.substring(msie + 4, ua.indexOf(“.”, msie)));

return ieVersion;
}
// If IE Version > 10, return version number
if ((msie == -1) && (rv > 0))
{

// If IE Version > 10
ieVersion = parseInt(ua.substring(rv + 3, ua.indexOf(“.”, rv + 5)));         r
eturn ieVersion;
}
}

Hope it helps..

Make Enable / Editable field on Assign of Entity Record


To Enable the field on Assign of any entity record, call the below function. On Assign of record, only save event triggered in CRM 2013, so we have to call the function on OnSave. Check the Save Mode for Assign( Save Mode of Assign = 47) and write your logic there..

function EnableFieldOnAssign(prmContext)
{
if (prmContext.getEventArgs().getSaveMode() == 47)
{
Xrm.Page.getControl(“mst_casestatus”).setDisabled(false);

}

}

Hope this helps..

%d bloggers like this: