Category Archives: Microsoft CRM

Create a AutoNumber field from your existing Text field in Dynamics 365/ CDS.

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Well this has long been awaited for. And how many  times I had my customer walking up to me and ask – “I have an existing field. Do CRM provide Autonumber feature? Can I convert an existing text field to AutoNumber field?”.

Till this point my answer was Yes but with a suffix“but” in it.

However going forward you can with the new entity designer in power apps.

So you can select Primary Attribute Number field of your entity and covert it to AutoNumber type now.

Below I open the OOB Account Number field and set the Data Type from Text to AutoNumber.

image

Short and sweet. Isn’t it?

P.S – Only existing text fields could be converted into Auto Number Type. You can off-course create a new Auto Number Type field.

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)

Advertisements

Enable Custom entity for email in Dynamics 365/ CDS

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

After my last blog on canvas app and OPEN API, I would say this one is pretty basic. However time and again I keep hearing kind of similar questions based on this topic and hence I thought of penning this blog.

Well there are two questions usually that I face.

  • How do I make my custom entity emailable?. In other words, how can I select my custom entity in the To, CC, BCC section of email?

  • If I have more than one email field already available before I enable this setting, which one would it take while sending email?

Well the first one is quite easy and I think majority of us know this. In case you are unware, you need to go to the Entity Settings and then enable the checkbox “Send email to Entity”

image

Well above is a view from the new powerapps admin center. In case you are still working on the old version, this is what it would look like.

image

Well you may be thinking what’s new. After all this is know. When we select this option, a new field of format  “Email” would be created and that will be used to receive emails from CRM.

Wait..but what about the second question?

Well in that case, the email field which was created first would be used for sending the email.

Small one but next time if someone pops this question, you can just steal the show by letting out this small secret.

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)

{Quick tip} Why is my Interactive Dashboard not showing up in Unified Apps.

Well this is very basic to say the least. But still sometimes in our regular day-day work we tend to miss out on one of the small steps and that eats into our precious time. If you already know this, there is no point in continuing with this blog. However if you are stuck in the same problem, may be this helps you out of peril.

A consultant walks up to me and informs that he has created a Single steam Interactive Dashboard but it is not showing in the Customer Service Hub or for that matter any other Unified Apps.

Advertisements

So before I actually walked to his desk, confirmed with few check lists.

  • Published the Dashboard –> Yes
  • Make sure it’s visible to everyone –> Yes
  • Re-opened your customer service hub application in browser? Sometimes cache is an issue –> Yes.

Yes to all basic verifications. No option but to walk up and verify and indeed the Dashboard is not showing up.

And finally the ingenious question which I could only think of – Did you include this Dashboard in your APP? The answer came – NO

Advertisements

So here it is guys, unlike class Web interface, to make a dashboard appear in Unified interface, you need to add it to the Dashboard’s list of your APP. A unified APP is basically shown with the components you pick and choose.

  • Open your solution
  • In Model driven apps, add the APPS where your want to show the Dashboard.
image
  • Open the APP and in the Dashboards area, select your Dashboard from the Interactive Dashbaords section. Please note the procedure for classic dashboards is same.
Advertisements
image
image

And voila! you are done.

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)

CRUD operations using executeMultiple in Dynamics 365 WebApi

Just another day at office and yet another challenge. Looked a simple one at the beginning. Basically here is the requirement

“Multiple create and update operations needs to be performed using Dynamics 365 Web API through client side.”

Off-course we can use the Xrm.WebApi.createRecord or Xrm.WebApi.updateRecord but in that case for as many records, those many server side calls need to be made from the client side.

But Microsoft has covered our back right! We have the executeMultiple method. So what’s the fuss about?

Advertisements

Well although we have the method but how to make it work. So basically the executeMultiple will accept an array of request object. And to create the request object, we can easily fall back to the documentation of execute method.

Unfortunately the document lacks in showing how to perform a CRUD operation request object. And that’s the fuss is all about. Things like this believe me, would take you days to resolve.

Well not to worry. If you think that this is going to take away your night’s sleep, I have done that for you. So let’s jump straight to the action here. Check for the parts highlighted in yellow. There in lies all the tricks!

Advertisements

And here is how to create request object for CREATE. Below is the code to create a request object for Account create.

var cAccount = {};
            cAccount[“name”] = “CRUD Test”;

// put your remaining fields to create the account object.

            var request = {};
            request.getMetadata = function () {
                return {
                     boundParameter: undefined,
                    operationType: 2,
                    operationName: “Create”,
                     parameterTypes: {

                    }
                 };
            };

           request.etn = “account”;
            request.payload = cAccount;

Below is the code to UPDATE an existing account.

var uAccount = {};
            uAccount[“name”] = “CRUD Test – Update”;

            var request2 = {};
            request2.getMetadata = function () {
                return {
                     boundParameter: undefined,
                    operationType: 2,
                    operationName: “Update”,
                    parameterTypes: {

                    }
                };
            };

            request2.etn = “account”;
            request2.payload = uAccount;

request2.id = “<put your account id here>”;

And finally the execute multiple code.

Xrm.WebApi.executeMultiple([request, request2]).then(
           function (results) {
               debugger;

               // parse your results here
            },
           function (error) {
           });

Hope this will help many and save your time!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)

Create PDF document from files in SharePoint and send as an email attachment

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

I am very excited to announce the new Utility from XrmForYou stable – “SharePoint Document Merger”. Let’ directly jump to the Utility functionality and other details

So what does this Utility address?

You have an opportunity in CRM and you are using the OOB CRM-SharePoint integration to store documents in SharePoint corresponding to the opportunity. And now you need to combine all these documents into a single PDF and send it to your customer or team or anybody, over an email as an attachment

Advertisements

Well if this has bothered you and you are thinking on how to do this, you no longer need to worry. The Utility just does this and it has some other features as well which I am going to explain below. And all these with few configuration steps.

For trial and pricing, please write to us at info@xrmforyou.com

How does this work?

The tool comes in the form of managed solution. Once you get hold of the solution, you need to install the managed solution.

Advertisements

Once the solution is installed, open up the solution and navigate to its configuration page. The first section is to enter the license key which would be provided to you by XrmForYou.

image

You can do your entire Merge configuration by expand the section “Merge Configuration settings”

image

As you can see from the screenshot above you need to enter some details for the tool to work. The tool does not use a username and password. Instead it leverage OAuth2.0 to authenticate with SharePoint. All you need to do is register this tool as an APP in your Azure Active directory as Web  App/ Web Api.

Advertisements

Once the APP is registered you would need to enter the client_id and client_secret information of the APP here. The client_secret is stored inside CRM and is protected by encryption

Azure Application Url is the URL of the Sharepoint.

MergedFileName is the name of the Output file.

Once you save your merge configuration settings, that’s all you need to do.

Now let’s see it in action.

I have an account below where I have uploaded 4 files.

  • One excel
  • One word
  • One PPT
  • One pdf
Advertisements
image

Since Merge Configuration has been enabled, a new ribbon item would start appearing in all the entities which has been enabled for Document Management. So in Account entity form I could see the Merge Button.  This would be show automatically and no configuration is required from the customer side.

image

Advertisements

Once you click on Merge document you would get the below message:

image

Within a moment you should see the the merged document containing all the contents of the merged file.

image

Wonderful isn’t it? The PPT, excel, word and the PDF file have merged into a single file. The file will bear the same name as you provided in the configuration. And yes before you ask, it works on the Unified interface as well.

Advertisements

And finally the output file. First page – the word document

image

Second Page – the excel

image

Third Page – the powerpoint

Advertisements
image

Wait the show is not over. We are releasing the utility with two versions. One with the option to generate just the merged file and the other with the option to send the merged file as an attachment over email. So once the merge completes, you can hook in and put in your code to send an email automatically or do anything you like with the generated document.

The content of the document, the record context everything would be available and you can play with it!

Advertisements

What’s not there in this release?

We don’t want our customers to have sudden surprises once they are into using it and duly I present some of the stuffs which we are already working on for the next release but is not there in the current version!

Advertisements
  • Documents are merged in descending order of modified on date.
  • Currently only the specified formats are supported – csv, doc, docx, odp, ods, odt, pot, potm, potx, pps, ppsx, ppsxm, ppt, pptm, pptx, rtf, xls, xlsx.. Going to change very soon with the next release. Stayed tuned for the next update in couple of months time.
  • Support for OOB sharepoint document location only. Next release in the coming 2-3 months support multiple document location merge for each record.
  • Available only for online customers.
  • Output file is only pdf format.

So what’s keeping you waiting. Just drop us a note at info@xrmforyou.com to grab your free trial.

Documentation and video to appear in our website www.xrmforyou.com by next week. Stay tuned!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)

Get formContext in HTML Webresource in Dynamics 365

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

If you are using on the latest version of Dynamics 365/ CDS online, Microsoft API can you help you do that. A better and supported approach is described here.

Xrm.Page is deprecated. We all know and we have already started revamping our form scripts and replacing Xrm.Page with formContext and gridContext as suggested by Microsoft.

Advertisements

But the ordeal does not end here. And recently I was faced with another challenge. Customers had HTML webresources embedded in their form where they are playing with the form controls using parent.Xrm.Page.getAttribute and parent.Xrm.Page.getControl.

So we thought of removing Xrm.Page from within inline HTML webresources as well. But wait, there is a problem here. How do we get formContext here.

Advertisements

Searched the heck out in Microsoft Docs but could not find a way. Came across this documentation in Microsoft Docs which I think everybody know anyways. It still asks to use parent.Xrm.Page. But our customer wanted to remove all traces of Xrm.Page at one go.

image

Then how to proceed. First things first. Is there a way to access the formContext inside HTML webresources?

I could not find any. But I believe you can solve so many things by a good design. And I implemented one of it here to solve the problem. My customer liked it and I hope you would like it too.

Advertisements

So I have this custom entity inside which contains a HTML webresource embedded within it. The first thing I did is to store the formContext in a global variable. So I registered a library on form onload of the test entity. Below is the code for the same. I am using namespaces here for better coding convention

// JavaScript source code
if (typeof (ibtrng) == “undefined”) {
    ibtrng = { __namespace: true };
}

ibtrng.formevents = {
    fContext: null,

    onload: function (e) {
        debugger;
         var fContext = e.getFormContext();

Xrm.getParentAttribute = function (attrName) {
            debugger;
            return fContext.getAttribute(attrName);
        };

        Xrm.getParentControl = function (attrName) {
            debugger;
            return fContext.getControl(attrName);
        };

       
    }

};

Advertisements

The code highlighted in yellow just sets the formContext in a global variable.

Check for the code highlighted in green! What am I doing here? Well from the screenshot of Microsoft Docs, it is evident that within the embedded HTML page you can get hold of the Xrm context using parent.Xrm.

So in the parent scope, during from onload, I registered two custom functions in Xrm namespace – getParentAttribute and getParentControl which is internally using the formContext only.

You can define as many custom functions as you want in the parent scope of Xrm namespace.

Advertisements

And now when the HTML page loads, I can get access to the form data. For the sake of this demo I just populate the textbox field on my HTML with the data of the form. Below is the code on load of my HTML Page

function onHtmlPageLoad() {
             debugger;

            var attrName = parent.Xrm.getParentAttribute(“ibtrng_name”);
            var attrValue = attrName.getValue();

            document.getElementById(“txtName”).value = attrValue;
        }

Screenshot

image

And voila! I can access data without even any trace of Xrm.Page.

Now the bigger challenge – Does it work on UCI? No solution is complete these days if it does not work on UCI.

Works like a charm in UCI too!

image
image

Hope you liked it!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)

Object reference not set to an instance of an object – error in Dynamics 365 plugin registration tool

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

To be honest, I have been getting this error for quite some time now, every now ever since I started working with Dynamics 365 SDK. And believe me it can give you a nightmare.

Plugin registration tool is one such utility which we use everyday without much notice but as soon as it stops working, life of a CRM consultant becomes a living hell. And I find lot of consultants facing this recently.

Advertisements

No worries you are on the right page towards solving. All you need to do is go ahead and delete the contents of the folder – C:\Users\<username>\AppData\Roaming\Microsoft\PluginRegistration and you should be good to go.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)

How to run a WorkFlow using client script in Dynamics 365 – Xrm.WebApi.execute

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

A very interesting read from my colleague

Advertisements

Integrate Dynamics 365 Plugin with Azure relay Hybrid connections. And it’s not using service endpoint

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Recently I have been working on Azure integration with CRM a lot and frequently I see azure relay hybrid connection integration with Dynamics 365. And in most of the case, it is through registering the Service Endpoint in Plugin registration tool.

While the above works really great for most of the scenarios, sometimes it becomes necessary for us to post something else apart from CRM context information. Sometimes it’s not even important for us to have the whole context information pass through but some custom values to the listener based on some business logic.

Advertisements

Since I have been queried about that a lot, I decided to pen this one down for the benefit of my readers.

I am  not going to show here how to set up a relay with Hybrid connection enabled. There are awesome articles which explains these. Just as a pre-requisite I am assuming

  • Azure relay with Hybrid connection is set-up
  • The Hybrid connection is set for authorization
  • You have the Send and Listen shared access policies set up for the Hybrid connection
Advertisements

Screenshots of my Hybrid connection with sender and listener profiles with CRM acting as the sender.

image
image
image
Advertisements

Now coming to code.

The first thing is I set-up a plugin which will fire on create of account. To call the Relay Hybrid connection from my plugin, I use the awesome Microsoft.Azure.Relays Nuget package which I think is simple awesome.

image

Below is the code I write to invoke my Hybrid connection from my plugins.

public void Execute(IServiceProvider serviceProvider)
        {
             var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            SendToRelay(context).GetAwaiter().GetResult();
        }

        private async Task SendToRelay(IPluginExecutionContext context)
         {
            var hybridConnectionName = “<hybrid connection name>”;
             var relayUrl = “
<a href=”https://.servicebus.windows.net&#8221;;”>.servicebus.windows.net”;’>https://<your relay name>.servicebus.windows.net”; // put your relay URL without the hybrid connection name
            var connectionKey = “<primary key for the sender profile>“;// put your primary key for the sender profile
            var keyName = “Sender”;

            var token = TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, connectionKey);
            var uri = new Uri($”{relayUrl}/{hybridConnectionName}”);

            var relayToken = await token.GetTokenAsync(uri.AbsoluteUri, TimeSpan.FromMinutes(30));

            HttpClient client = new HttpClient();

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri);
            request.Content = new StringContent($”{context.PrimaryEntityName}”, Encoding.UTF8, “application/json”);

            request.Headers.Add(“ServiceBusAuthorization”, relayToken.TokenString);
            request.Headers.Add(“CrmMessageName”, context.MessageName);

            client.SendAsync(request);
}

Advertisements

You would need to replace the one highlighted in yellow with appropriate values from your azure environment. As you can see from the above code I can pass my own data in the body of the request as well as pass some custom data in the headers collection. And as I using the Microsoft.Azure.Relay assemblies I need to do ILMERGE to merge this assembly with the plugin dll. For this I again use the wonderful MsBuild.IlMerge task available in Nuget

image

I am not awaiting for the result to come back since my relay can perform some lengthy operations. However in case I want to get the return values from my relay listener, I can just change the last few lines like this.

var responseMessage = await client.SendAsync(request);
            var content = await responseMessage.Content.ReadAsStringAsync();

Now coming to the listener, I just create a console application and keep it running. Below is the sample code for a listener. The code is courtesy Microsoft Docs and is also using Microsoft.Azure.Relays Nuget package.

static async Task RelayListener()
        {
            // create a connection string with the listener profile
            HybridConnectionListener listener = new HybridConnectionListener(“<put the connecting string of Hybrid listener>“);

            listener.Connecting += (o, e) => { Console.WriteLine(“Listener is connecting to Azure…”); };
            listener.Offline += (o, e) => { Console.WriteLine(“Listener is about to go offline…”); };
            listener.Online += (o, e) => { Console.WriteLine(“Listener is online…”); };

            listener.RequestHandler = (context) =>
            {
                 StreamReader streamReader = new StreamReader(context.Request.InputStream);
                // reading the body
                 var requestContent = streamReader.ReadToEnd();

                // reading the headers
                foreach(var header in context.Request.Headers)
                {
                    //Console.WriteLine($”Header Key: {header}, Header Value:{context.Request.Headers[0]}”)
                }
            };

            await listener.OpenAsync();

            await Console.In.ReadLineAsync();

            await listener.CloseAsync();
        }

Advertisements

And finally with my console running, if I create an account, the relay listener immediately catches this.

image

Wonderful isn’t it?

Hope this helps

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)