Custom ribbon buttons not showing up in Dynamics 365 forms/ grids. The wonderful Command checker tool from Microsoft might just save your day.

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 have ever worked in Dynamics 365 implementation then it is almost certain that you must have played around with ribbons. And more often than not you must have faced scenario where you have multiple enable and display rules on the form and not sure why the ribbon button is showing up on the form when it is supposed not to show up or vice versa.

And what we do to resolve it. Well, we play around with the ribbon customizations which takes much more time than other customizations in Dynamics 365. And if it is some custom rule, we would attach debuggers to our custom code and debug and find what is going wrong.

Advertisements

What if I tell you that Microsoft just released something which shall help you identify which of your ribbon rule is evaluating to what in a matter of few mins so that you can pin-point to the exact rule which is the culprit. Ta-da! Introducing to you the new Command Checker from Microsoft. You can find the details about the release right here.

In this blog I shall show you some scenarios.

So let’s take a simple example here. I have inserted one custom button called – “Command Checker Test” on the Contact form.

I basically have two rules for the custom button.

1. One display rule – CommandClientTypeRule to show it only on Modern interface.

image

2. A custom rule where I am returning true or false based on some business logic.

image

It’s the most complex logic I could have thought of in the Cornona Lockdown and don’t beat me up for this. Smile

function showHideCommandChecker(fc) {
     // sample code.
     var jobTitle = fc.getAttribute(“jobtitle”);

 

    if (jobTitle.getValue() !== null) {
         return true;
     }

 

    return false;
}

Advertisements

And now comes the grand entrance of the “Command Checker”. I open up a contact record. My button is right there. But wait where is the command checker. It ain’t there?

image

It’s a magic wand. You just don’t get it. You have to conjure it up. And the way to do it is just by appending a query string parameter “ribbondebug=true” to the URL of the entity record

image

And now you see the command checker tool. If you don’t see it, it might be hidden under your ellipsis area like in mine case too.

image

What happens when we click it? Magic!

image

You have all your ribbons buttons with their command and actions. Let’ select our Command Checker button.

Advertisements

If I check the command properties, I can see which rules evaluated to true or false so that you can identify why the button is being shown or rather not being shown.

image

As you can see from the above screenshot, we can see the enable rule and the display rule being both evaluated to true. Wonderful isn’t it? We know exactly which rule evaluated to what.

Not only that, when we have multiple solutions installed, we can even see which solution is in effect by viewing the rule definition and solution layers.

I will leave it here and you can explore more detail in the Microsoft link here which is mentioned above as well. And guess what, I just loved exploring it while I was penning this blog down.

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)

Stay on the same page when a lookup field is clicked in Dynamics 365 forms/ grids. Use the addOnLookupTagClick function

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

With every release of Dynamics 365, there is something always new for developers. In my last blog I explained about the enhancement in Xrm.WebApi.navigateTo method. Today we will discuss in detail about the new “addOnLookupTagClick” method introduced in Release wave 1, 2020.

So what does this function do? Actually it solves a long standing problem where clicking on a lookup value, it redirected to the lookup record form. A potential problem with this is the user would lose context of the record they are working on. But now this can be avoided. So let’s see how we can achieve the same.

Advertisements

For this demo I use the Account form, Parent Account (parentaccountid) field.

In the onload of the Account form, I add the below code.

Xrm.Page.getControl('parentcustomerid').addOnLookupTagClick(function(e){ 
e.getEventArgs().preventDefault(); // disable the default behavior which to open the lookup record. 
// get the lookup record value 
var lookupRecord = e.getEventArgs().getTagValue(); 
// get formContext 
var fc = e.getFormContext(); 
});

The two most important part of the code are inside the function with comments. The first one is to prevent the default behavior which is navigating to the lookup record.

Advertisements

The next one is even more important which allows you to select the lookup record clicked. I used the developer tools to show you the format of data returned by function.

The final line of code is to get the form context.

So what actually we can achieve with this. Well a lot. You can open up the lookup record form in a dialog as I explained in my previous blog.

Or may be you can open up a webresource to show up anything. I mean anything that your customer need or want.

Advertisements

Debajit Dutta

(Dynamics MVP)

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

 
 

How to Show Dynamics 365/ CRM form in a modal window? Use Xrm.Navigate.navigateTo

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

With PowerApps release wave 1 2020, Microsoft have released quite a few features under the hood. While some  have hogged the limelight, others continue to evolve in the platform like hidden gems. And one of them is the enhancement in much loved Xrm.Navigate.navigateTo API.

Now with this API you can open an entity record modal and that too with the choice of form you want.

Advertisements

While this blog teaches you on how to do all this using sample code, this kind of feature is actually going to save you loads of time. Imagine you wanted to show specific record form as modal while working on something else. And previously you would require to develop a HTML web resource and map the values back to D365 record. Now you can just use few lines of code to do the same.

Below the sample code piece to open a contact record. Please note as of the current version, only form of type Edit is supported.

Xrm.Navigation.navigateTo({
pageType: “entityrecord”,
entityName: “<put your entity logical name here>”,
formType: 2, // you can only open a form in edit mode as of now. Other form types are not supported.
entityId: <put your record id here>
}, {
target: 2,
position: 1,
width: 700,

       height:600
});

Advertisements

And below is what you see.

image

Awesome isn’t it? Now one problem here is the record will open on the default form. What if you want to open the record in a form of your choice. Well here you go.

Xrm.Navigation.navigateTo({
pageType: “entityrecord”,
entityName: “<put your entity logical name here>”,
formType: 2, // you can only open a form in edit mode as of now. Other form types are not supported.

    formId: “<put your formid here>>”
entityId: <put your record id here>
}, {
target: 2,
position: 1,
width: 700,

       height:600
});

Advertisements

I wrote some code to open it in Information form as you can see below, it did just that

image

Hope this helps!

Debajit Dutta

(Dynamics MVP)

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

Custom Button on Entity form to Save a record in PowerApps portals/ Dynamics 365 Portals

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 had a requirement where my customer asked me to put an additional button on the Edit page of a account form that will perform a set of operations before saving the record.

They didn’t want to tamper the OOB functionality of Submit button that comes with the portal. So basically on Account edit form, you should have two buttons, one OOB submit button and other the custom button – “Validate & Save”.

Advertisements
image

On click of Save & Validate, some custom validations shall be performed and then the record should save with the same behavior of click of Submit button.

Advertisements

So there has two steps to it.

Step 1 : Create the button

Trust me this one is easy with a little bit of DOM element modification. In the Custom Javascript box of the content web page of Entity form, paste the below script.

$(document).ready(function () {

$("div.actions").append("<input type=’button’ id='btnSaveValidate' name=btnSaveValidate’ value='Save &amp; Validate' class='submit-btn btn btn-primary form-action-container-left' />");

});

Advertisements

And the button would appear.Basically the submit button is inside a div element with class = “actions”. With a future release of the portal this may change. all you need to find the appropriate place to put in the button

Step 2 : Save the Record on Click of the button

The usual thought that comes to mind is we will submit the form. Something like this should work

document.forms[0].submit();

But unfortunately it does not work out. This is because saving the record is being handled by server side event handler of the OOB Submit button. So basically you need to mimic the call of the submit button.

And the below code does just that.

$("#btnSaveValidate").bind("click", function () {

// perform your own logic here.

WebForm_DoPostBackWithOptions

(new WebForm_PostBackOptions($(this).prev().attr("name"), '', true, '', '', false, true));

});

Advertisements

All I need is to pass the name of the Submit button in the WebForm_PostBackOptions and this is achieved by using $(this).prev().attr(“name”). And now the server side event handler for the Submit button is called and the record is saved.

And now you are all set and running. You might think why not trigger the client click of Submit button. Well this can be done off course. But then you execute the client side logic if any of the submit button. Our intention was to put custom client side validation and then invoke the server side handler to save the record.

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

Quick find view search not working in Dynamics 365? There is Change in Default Search behavior in Dynamics 365 in release wave 1

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 one came as pure surprise and I got to know of this one only after one of our customer enabled 2020 Release wave 1 feature in one of their SandBox environments and updated us that search on entity grids is not working as excepted.

Let me explain the scenario here. My customer was searching in the opportunities grid and the view that he was currently  in was “Open Opportunities”. Can’t use my customer environment for this blog. Hence using the screenshots of a vanilla environment with Release Wave 1 2020 enabled.

image
Advertisements

If I search on this view with the word Kitchen, our expectation is Dynamics would use the Quick find view to identify all the records matching with kitchen and show the results. But surprisingly it didn’t happen.

image

However in the list of all opportunities, there is indeed an opportunity with topic “Kitchen appliances”. And as per the quick find view configuration of opportunity it is supposed to return that.

image

This one took us completely by surprise. Personally I had no clue of what was happening. The only difference we could make was this started happening after we enabled Release Wave 1 2020 in their SandBox environment. And for the customer it’s a feature they are so accustomed to and suddenly not working.

Advertisements

So we started digging the release notes and we finally found the hidden gem. You can read it here.

image

To be honest, it didn’t go well with my customer but I would keep that aside and jump more into the technical side of it.

Question 1 – “What is happening now by default?”

Well by default, Dynamics 365 or CDS searches in the view that you are in. If you observe carefully, the search textbox now contains a placeholder text – “Search this view”

Question 2 – Can I go back to the previous behavior – Searching based on Quick Find view?

Fortunately, the answer is Yes. You would need to go Settings –> Administration –> System settings and set the value below setting value to yes.

image

Question 3What happens to Categorized/Global search?

The categorized search still used the Quick find view.

What’s my opinion on this feature? It’s a long awaited feature and Microsoft did a great job implementing the same. However would have been better if they hadn’t made it the default behavior in entity searches. This can take your customers by surprise.

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)