Thursday 31 May 2018

Dynamics CRM: HTML Games


In Microsoft Dynamics 365 we can create multiple Add-ons with help of capability of HTML, Javascript and CSS.

Now these HTML 5 is becoming more popular and powerful and most of the browser start supporting HTML 5. HTML 5 give us some more interesting elements. Today I will discuss about “Canvas” element of HTML5.

HTML Canvas: -
                                Canvas is an element of HTML5 which in use to draw graphics in our html web resource.

We can also create runtime “Canvas” element in our HTML with help of Javascript.   We can think canvas as MS Paint board and with help of Javascript we can draw line, circle, square text, images. We can are also add motion in our elements of canvas.

We will look two examples to understand use of canvas.
  • Clock
  • Moving Square Game.

In the end I will also share solution that you can import in your CRM online trails and Play the game.













Clock: -
                To create Clock, we will use arc method to draw clock outline as circle. We will use fillText method to draw numbers. And lineTo method to design hour, minute and second hands.
We will also use setInterval Javascript function, so our clock should show as real clock.
Moving Square Game: -

                                                In this example we will create a Game for Dynamics CRM. This game needs a moving Square box, some Obstacles, a score counter and event handler for buttons and handlers for keystrokes.
We need to move our square box so it should not touch obstacles. If obstacles touch the screen than game over and need to restart the game.


We can store our scores in CRM and can give some points to winners.

Special thanks to W3school.com to help learning.

Now start your imagination and build some look add-ons for Dynamics CRM.


Please follow to be update for my blogs.



Tuesday 15 May 2018

Dyanmics CRM : Change Version


Microsoft provide us liberty to create Trial version of Dynamics CRM. When we create a new trial, version of Dynamics CRM it always creates latest available version of Dynamics CRM.


But there are few scenarios where we need lower versions of Dynamics CRM.
  • Our client working on previous versions.
  • We have any solution which created in lower version.
  • We need to compare our solution in different versions.
  • We need previous versions for study.

Now I will demonstrate who you can downgrade your Online trial version.
Note: - Microsoft allows to downgrade version up to three previous versions.

Currently, when we create a new trail version it will create in Dynamics 365, version 9.0.
It will look like.











Declaration: - When you downgrade your CRM you will lose you all data and customization. So, play with care.
Now, we want to downgrade our latest trial version so follow these steps.
Make sure you are global admin. Go to admin panel 






































Expand “Admin centers” tab and click on “Dynamics 365”





































It will open Instance Picker page. So now select your organization and click on “Edit” button.

























Change Instance Type to “Sandbox”. This is required because we are not allowed to change version of production instance.






































After changing instance type, when we select our sandbox instance we will see more option in right had side.























Now click on “RESET” button.

 Now we can select our desired target version. We can select in between version 9.0, version 8.2 or Microsoft Dynamics CRM Online 2016 Update 1. We can also use other option like name change etc. as per our requirement.
























And click on reset button.
 It will take some time. It can take 15 minutes to 1 hour to configure your changes.




















After these changes are done you can change “Instance Type” again back to production.
Login to your CRM organization. Now you will see your Trial version changed and have no solution there.

Please follow to be update for my blog.

Wednesday 9 May 2018

Dynamics CRM : Composite Fields


Dynamics CRM provide Composite Address for Lead, Account and Contact entity. Currently there is no option to create custom composite attribute Might be in future Microsoft provide this capability.
In this article we will understand below topics: -

  • Composite Field
  • Lookup attribute filter
  • Passing message(Event) from CRM form to HTML web resource
  • Sending Parent Control in open form
  • Download Solution


1. Composite Field: - 
                                     As name says composite field is made of two or more fields. Before Dynamics CRM 2016 Address was only composite field preset in CRM, but now we have two composite attributes.
First Address attribute and second is Customer attribute.

At database level separate table is created to handle composite attributes.
Example: - When we create a new account in CRM from web, console, integration etc. (Except SQL insert query-not recommended, but possible) with or without address. Two records are created in address table for that account. This address table contains Guid and Record type for reference of created record.
Customer Attribute is special type of attribute which contain reference of account and contact entity. For Customer attribute also have different table created at database level.

Difference between Address and Customer composite attribute is we can create custom Customer attribute for our entity, but we cannot create custom composite Address.

2. Lookup attribute filter: - 
                                               From Dynamics CRM 2016 onward, we can configure filter for our lookup without use of any Javascript code. To enable lookup filter target entity must contains in source entity and target entity must contain in current entity.
Working: -
Current Entity: Composite Field
Source Lookup: State lookup
Target Lookup: Country lookup










































Open form editor and select state attribute and click on change properties. In Display tab we will see new “Related Record Filtering” option.
Now select country attribute and contains state.



For this filter State entity must contains Country lookup.


After this configuration when we select country, state will only show for selected country.


3. Passing message(Event) from CRM form to HTML web resource: - 
                                                                                                                    As we know we can use Dynamics CRM XRM library in our HTML web-resource with use of window.parent
window.parent.Xrm
But passing information from CRM form to HTML web-resource is little compilated.
It involves two step processes
First, create a function in Javascript an register onload, OnChange, OnSave or any other form event to post message to html web resource.
Second, create an event listener in your HTML web resource to process message.

Example: -
Create JavaScript web resource and add function to Post message to HTML web resource.

function CompositeFieldFunction()
{
   
    if (Xrm.Page.ui.controls.get('WebResource_CompositeHtml')) {
        var iFrame = Xrm.Page.ui.controls.get('WebResource_CompositeHtml').getObject();
        var sav_address = window.parent.Xrm.Page.getAttribute("sav_address").getValue();
        if (sav_address) {
            iFrame.contentWindow.postMessage({ 'addressDiv': sav_address[0].name }, '*');
        }
        else
            iFrame.contentWindow.postMessage({ 'addressDiv': "Click here to add address" }, '*');
    }
}

Friday 4 May 2018

Dynamics 365: TLS connection Issue

In Dynamics 365 after release of version 9.0 we started facing issue while connecting to Dynamics CRM in our console , window etc. application.

You will face below issue.

{"The underlying connection was closed: An unexpected error occurred on a send."}











Solution: -

Reason behind this issue Dynamics 365 version 9.0 following TLS 1.2.
That means you are not able to connect Dynamics 365 until you enforce TLS 1.2 before your connection.

So you need to use below code before creating connection.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;















After adding this code you will able to create connection successfully.

Due to TLS 1.2 our plugin registration tool stopped working for Dynamics 365 9.0 or online trial version. Can need to download new plugin registration tool either from Nuget. or download from below link.
 Plugin Registration 9.0

Thursday 3 May 2018

Dynamics 365: Generic Assembly


Dynamics 365 extended their capability with help of workflows and actions.
Even we can create UI workflows in Dynamics 365 easily. But still we need custom workflows, plugins and action to meet user requirements.
To create any custom workflows, plugin we need knowledge to .net and any supported language like VB or C#.
To meet this requirement, we are trying to create a generic assembly which can be used by any organization without any cost and development.
You just need to download this solution and install in your organization and start using it.



Currently, this assembly contains below features. In future we are going to enhance their feature count in upcoming new versions.
You can also share your feedback and generic feature to added in comment section.



Features: -

CheckUserInTeam: -
This feature is created as custom workflow. If you want to check specific user present in specified team or not this workflow can be used.
Working: - This workflow contains Two Input parameters named User(System user lookup) and Team(Team lookup)  and One output parameter named IsAvaliable (Boolean).
You need to provide value in User and Team lookup and this workflow will check is user present in given team or not and return result in true or false in IsAvaliable output parameter.

SendEmailToQueueMember:  -
This feature is created as custom workflow. Currently in Dynamics 365 do not have any out-of-box option to send email to queue members.
 So, if you want to send email to all Queue member this workflow can be used.
Working: - This workflow contains Two Input parameters named Queue (Queue lookup) and Email (Email lookup).
You need to provide value in Email and Queue lookup. You can use OOB workflow to create email and then use this custom workflow to send email to all queue member. In this custom workflow we are retrieving all queue members and adding to email “TO” list then custom workflow will send this email via code.
















Make sure all queue members have valid email Id. And email have valid value in email “From” attribute.



GetUserTeam: -
This feature is combination of System Action and Plugin. Currently in Dynamics 365 we can retrieve current user roles using Javascript.
Xrm.Page.context.getUserRoles()
But we do not have any option to get all teams of specified user.
 So, if you want to get all Teams to specific or current user you can use this feature.

Working: - This workflow contains One Input parameter named User (System user lookup) and One Output parameter named UserTeam (Team EntityCollection)
As we know entity collection parameter is not allowed System or Custom workflow But Dynamics 365 allow use “EntityCollection” in Action process.
So, We have created one Action that will take user as input parameter and return Team as entitycollection.



This action will call our plugin code that will retrieve Team for given user.

Limitation: - You can’t call this action from System workflow because it contains entityCollection argument which is still not supported by workflow. May be in future release Microsoft allow entitycollection in workflow also.

So, You need to call this Action from Javascript Code.

In given Solution you will find a webresource named “sav_/scripts/jswr.js” that have function “GetTeam” Which you can use to call this action. In result “Team Name” and “TeamId” is displaying in browser console. You can add your required code there.


Click on Follow to be update about my new blogs.











Field Security Profile - Based on Owner

 Recently received requirement related to Field security profile. Expectation : - 1.       Set to users need access of secure attributes. 2....

Test