Monday, November 4, 2019

Show Plugin Error Message on Dynamics Portals - Site/EnableCustomPluginError Setting

Hi Everyone,

Today I was working something on Portal and we do have some validation at the plugin and throwing an InvalidPluginException based on some business logic. However on the Portal, we were not seeing the same message. It was saying something as "An unknown failure has occureed. Error ID ...".


After some quick search, was able to figure it out that there is a Site Setting which needs to be created to get the same messages from plugin to be shown on the Portal UI.

Navigate to Portal -> Site Settings and create a new record as below.

Name - Site/EnableCustomPluginError
Website - Whatever you have like Partner Portal, Customer Self-Service etc..
Value - true
Try to do the operation which triggers the plugin that throws the error and you will see the same on Portal UI.
Hope this helps.

--
Happy 365'ing
Gopinath

How to configure the logo for Portal - Branding

Hi Everyone,

As we all know Branding is the one which everyone wants. When we setup Portal, we see Contoso, LTD as a text at top left and the Customer might want the Company Logo there or may be some text. 

Here are the steps to change the Branding.

1) Create a Web File with Name, Website, Parent Page and Partial URL.
2) Attach the image to the Notes of the Web File created.
3) Navigate to Content Snippets and in the value(HTML), add a image tag with SRC as the PartialURL given in the Web file.

<p><a class="homelink" href="~/" title="MyPortal"></a><img src="/myportallogo" alt="Microsoft" height="42" width="42"></p>
4) Save the record.


Hope this helps.

--
Happy 365'ing
Gopinath

Thursday, October 31, 2019

Hide links from Primary Navigation in Dynamics 365 Portals

Hi,

Many times, we get the requirement to hide the links in the Primary Navigation of the Portal to the anonymous users.

To get this done, we have to create Web Page Control Rule

Navigate to Portals -> Web Page Access Control Rules -> New

Give the name and select the Website and WebPage that has to hidden.
Right - Select Restrict Read and Save the record.
After saving, go to Web Roles tab and add Authenticated Users web role to it.

Authenticated User
Anonymous User


Hope this helps.

--
Happy 365'ing
Gopinath

Tuesday, October 29, 2019

Add a custom button on Web Page - Dynamics 365 CE Portals

Hi,

Today when I was working on Portals, I got a requirement to add a cancel button beside Submit button on EntityForm and user has to navigate back to EntityList when click on it.

We can quickly do this by adding some script on the WebPage. Open the required WebPage and there is a tab named as Advanced and add the below code. I have used SiteMarkers to navigate. 


$(document).ready(function () {
    $('#InsertButton').after('<button id="cancelbutton" type="button" class="btn btn-primary button" style="margin-left:10px;"><span></span>Cancel</button>');
    $("#cancelbutton").click(function () {
        window.location.href = "{{ sitemarkers['ML_CustomEntityList'].url }}";
    });

});

Make sure you add the same piece of code in all Content Pages. 

Hope this helps.

--
Happy 365'ing
Gopinath

What are Site Markers in Dynamics 365 CE Portal?

Hi,

I was searching something on Portals and reached on Site Markers. Some how I felt that Site Markers are not used much in the Development of Portals. 

Many times we get a requirement to navigate to multiple places on click of buttons and we use Window.location and use the direct URLs or may be we some hyperlinks on Portal and we directly give the URL of the Web Page which works good until someone changes the Partial URL on the Web Page.

Site Markers are something which are designed for this. We have to create Site Markers and link the Web Page that is need and use Site Marker Name in the code to navigate. Here is the syntax for the same.

{ { sitemarkers["SitemarkerName"].url } }

Changing the name of the Sitemarker is strictly prohibited. This way, we don't face any issues even if the Partial URL on Web Page has changed. 

Hope this helps.

--
Happy 365'ing
Gopinath

Retrieve Dynamics 365 CE data in Portal by using Odata Feed using JavaScript

Hi,

Today I have some requirement to get some data from CE and show it on the UI. We can do it very easily by doing a OData call. 

Here are the steps to be followed for the same. 

1) Create an EntityList with the required entity. Make sure you select the view, Enable Entity Permissions (if you uncheck this, you will see 500 Error as you don't have the permission to view the data).

2) Navigate to OData Feed tab and enable it. EntityTypeName and EntitySetName are textboxes, you can give as per your wish and then select the view.

3) Hit the browser with your portal URL and "/_odata"
   https://abc.microsoftportals/_odata
4) You will see the list of entities on which Odata feed is enabled.
5) Now you can hit browser with the name that was given and you can see the results. https://abc.microsoftportals/_odata/ContactSet

In case if you are not seeing the results, please check Entity Permissions and give the right permissions.

6) You can use below code by passing OdataURL and it will get the results for you.


function getResponse(oDataUrl) {
    var response = null;
    $.ajax({
        type: "GET",
        url: oDataUrl,
        dataType: "json",
        async: false
    }).done(function (json) {
        response = json.value;
    });
    return response;
}

Hope this helps.

--
Happy 365'ing.
Gopinath

Tuesday, September 24, 2019

Asynchronous processing of cascading transactions

Hi,

Processing of Cascading Transactions plays a crucial role when you are working with the big engagements and dealing with entities where you have many child records. You might have not observed this on the lower instance like Test, UAT, SIT or whatever but I am sure that Synchronous processing of Cascading transactions would be resulting slow performances on the Production as we have more data and transactions are being performed.

I know it's not so easy to discuss this with Customers and make them understand as mainly it deals with data integrity as if something fails someone has to monitor System Jobs. However, It's worth to discuss with Customers and make them understand the consequences and take an action.

Go through Microsoft Docs for more information.

Hope this helps.

--
Happy CRM'ing
Gopinath

Wednesday, September 11, 2019

Retrieve Cases associated with Contacts and Accounts in one go

Hi Everyone,

Today I was working on some work and got a requirement to get Cases of linked with Account and Contact. 

In a normal scenario, we can always do two Calls like 

Cases where CustomerID = Account GUID and 
Cases where CustomerID = Contact GUID

Somehow, I didn't like this approach of making two calls. Spending sometime helped to reduce a call and I was able to retrieve Cases related to Account and Contact in one call.

Here is the FetchXML I have used and uitype plays a major role here.

            <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                      <entity name='incident'>
                                        <attribute name='title' />
                                        <attribute name='ticketnumber' />
                                        <attribute name='createdon' />
                                        <attribute name='incidentid' />
                                        <attribute name='caseorigincode' />
                                        <order attribute='title' descending='false' />
                                        <filter type='and'>
                                          <condition attribute='customerid' operator='in'>
                                            <value uitype='account'>{ACCOUNT-GUID}</value>
                                            <value uitype='contact'>{Contact-GUID}</value>
                                          </condition>
                                        </filter>
                                     </entity>
                                    </fetch>

Hope this helps.

--
Happy CRM'ing
Gopinath

Configure Auto Number fields from OOB UI

Hi Everyone,

We all know there is a new UI - WYSIWYG is out for General Use and I was just trying something and found that we can create Auto number fields from new UI now. 

We used to use a piece of code to do in older versions, now with this new approach we don't need any code.

Login to CE (CRM) --> Customize the System --> Try New Experience.
Select the entity/Create a entity as per your requirement and select the field that needs to configured as Auto Number.


Hope this helps.

--
Happy CRM'ing
Gopinath

Wednesday, May 22, 2019

Operation returned an invalid status code 'Forbidden'

Hi

Today I was getting the below error while getting secret value.

Operation returned an invalid status code 'Forbidden'

After some search found that I have added the Web APP to Access Policies but never clicked on Save. Just make sure you have added the application in the Access Policies.

Navigate to Keyvault in Azure --> Open the required Keyvault --> Access Policies and Configure the Policy as below.

Configure form Template : Key, Secret and Certificate Management
Select Principal : Select the Application to which you want to provide access.
Key, Secret and Certificate Permissions : Based on your requirement.

Hope this helps.

--
Happy Coding
Gopinath

Logging in Azure Web APP

Hi,

Today I was developing an Web APP and it was giving an error after I host it on Azure. To understand the error I have log the traces. Here is the way that explains that how we can do that.

We can directly use Trace class (System.Diagnostics.Trace) for write the logs. I have written the below piece of the code as a first line in the method.


System.Diagnostics.Trace.WriteLine("I am getting called...");

Now navigate to your Azure Account --> The app service where you have deployed the Web APP --> Diagnostics Logs.


You have something called "Application Logging (Filesystem)" and you can switch it on. There are four options available there.

Error - Error, Critical
Warning - Warning, Error, Critical
Information - Info, Warning, Error, Critical
Verbose - Trace, Debug, Info, Warning, Error, Critical (all categories)

I normally prefer Verbose as it gives everything.

Now, browse the URL for hitting the action where you have written the tracing.

Navigate to Advance Tools under you AppService and Click on Go


It opens a new tab as below - Click on Debug console and then CMD.


You will see the below screen, click on LogFiles --> Application, you will see the .txt file. Click on Edit icon to see the logs.


Note : For Application logging, you can turn on the file system option temporarily for debugging purposes. This option turns off automatically in 12 hours

--
Happy Coding
Gopinath

Monday, May 20, 2019

Multiple actions were found that match the request

Hi,

I had written a new HTTPGet method and it worked well. After sometime, I got a requirement to write one more new HTTPGet method and I had troubles. The code started failing by throwing the below error.

"Multiple actions were found that match the request"

After some search I was able to identify the issue as we have to specify which action(method) we need send your HTTP request. For fixing it, we have to add routes in the WebApiConfig in the below order. The order plays important rule here. 

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
            name: "ControllerAndActionOnly",
            routeTemplate: "api/{controller}/{action}",
            defaults: new { },
            constraints: new { action = @"^[a-zA-Z]+([\s][a-zA-Z]+)*$" });

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

        }

Hope this helps.

--
Happy Coding
Gopinath

The return type of an async method must be void, Task or Task

Hi,

Today I was working on the some work related to KeyVault and I have written async method. The code was error as below. 

"The return type of an async method must be void, Task or Task<T>"



I tried internet and not able to get any answer for it and I was so worried :( as I was not able to understand the issue. It was in the early morning with half sleep I tried this and I thought, this needs some deep understanding and went for a coffee.

After sometime, I just opened the laptop and understood that I didn't the System.Threaing.Tasks namespace in the class file and it fixed the issue.

Moral - You need to take a small break when things are not working and start again if something is failing. Coffee helps :)

Hope this helps.

--
Happy Coding
Gopinath

Tuesday, April 16, 2019

The underlying connection was closed an unexpected error occurred on a send

Hi,

Today I was working on calling some external url via C# code using HttpRequest and I was continuously getting the below error.

The underlying connection was closed an unexpected error occurred on a send.

There could be multiple reasons for this but adding the below line before sending the request helped to fix the issue.


ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

Hope this helps.

--
Happy Coding
Gopinath

Tuesday, April 9, 2019

What is "Toast Notification Display time" in Dynamics 365

Hi,

Today I was working on some POC on a trail instance and observed that there is something called "Toast Notification Display Time" option under Settings on the Ribbon.

Let's try to understand what are Toast Notifications. For example, if you have created a record using Quick Create, you will see a message after creating saying "Your changes were saved" as shown below.

These are Toast Notifications and these will shown on the screen for some seconds and disappears. 

This particular setting Toast Notification Display Time will extend the notification display timeout to 10 times and it is default.

A quick search on this, make me understand this was added for Accessibility reasons.

Hope this helps.

--
Happy CRM'ing
Gopinath

Dynamics 365 – How to access Customizations, Solutions and Admin Features in UCI/UUI/UI Only Mode

Hi,

We all know that go forward way for Dynamics 365 is UCI and there was a major issue in that. Users has to switch back to classic to perform Admin actions. Microsoft PG heard our voices and released some easy ways to get it.

You can just click on Advanced Settings from the ribbon as shown below.

It will open a window with only Settings tab which has all Admin feature.



We don't need to worry about going back to classic and navigating. Now it is just a click.

Hope this helps.

--
Happy CRM'ing
Gopinath

Sunday, April 7, 2019

Add or Remove Components and workloads in Visual Studio

Hi,

We all know that at the time of installing Visual Studio, we get a window to select the components that we need for the development so that it automatically installs everything on the machine as per the selection.

Let's say you have not selected a component at the time of installation and later you have got a requirement to start on the new things. Here is the way to go back to the installer and select the things.

1) Search for Visual Studio Installer on your machine. 

If you cannot find that on your machine, alternatively you can check at the below location or give the below path in Run window.


C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe


2) Click or tap to start the installer, and then choose Modify.

If you have an update pending, the Modify button is in a different place. This way, you can modify Visual Studio without updating it, should you choose to do so. Click More, and then choose Modify.

3) From the Workloads screen, select or deselect the workloads that you want to install or uninstall.

4) Choose Modify again.
5) After the new workloads and components are installed, choose Launch

Modify individual components
If you don't want to install workloads to customize your Visual Studio installation, choose the Individual Components tab from the Visual Studio Installer, select what you want, and then follow the prompts.

Hope this helps.

--
Happy Coding
Gopinath

Thursday, April 4, 2019

Work Items opening in browser instead of Visual Studio

Hi,

Recently, I have installed VS 2017 and did set VSTS for one of my projects and started checking my work items. I have observed that we enter some ID on Go to Item popup, it is opening the item in the browser instead of Visual Studio. 

There is a setting that needs to setup in Visual Studio -> Tools -> Options -> Work Items -> General and select Visual Studio as shown in the screen shot below. 



Hope this helps.

--
Happy Coding
Gopinath

Thursday, March 21, 2019

Recent Items on the Lookup - D365 UCI


Hi,

We all know that with UCI we are getting number of good features and one of them in that is showing up the recent items on the lookup. Yes, it is a good feature for sure and sometimes we might have written our own filters and this recent items will not honor those rules.

The simple solution for this is we can disable this from the Lookup Properties.


Hope this helps

--
Happy CRM'ing
Gopinath

Wednesday, March 20, 2019

Refresh IFrame in Dynamics 365 UI or UCI

Hi,

We all very used to write the piece of the code from this link whenever we need to refresh the IFrame in CRM.

Very unfortunately, the same code is not working in Dynamics 365 UI version 9.x on wards. No need to worry on that, we have the work around for the same.

We have to pass the WebResource name if it has the full URL and vice versa. Here is the piece of the code for the same. I know, it is little confusion but we have live with it until the PG Team fixes the issue.


                var src = null;
                var newsrc = null;
                var url = Xrm.Utility.getGlobalContext().getClientUrl() + "/WebResources/";
                var iFrameName = "IFramControlName";
                var IFrameControl = formContext.getControl(iFrameName);
                src = IFrameControl.getSrc();
                IFrameControl.setSrc(null);
                if (src.indexOf(url) != 0) {
                    newsrc = url + src;
                }
                else {
                    newsrc = "abc.html";
                }

                IFrameControl.setSrc(newsrc);

Hope this helps.

--
Happy CRM'ing
Gopinath