Wednesday, December 27, 2017

How to use Angular JS in MS Dynamic CRM 365.

Step 1: Download the angular js lib. from Here.


Step 2: Upload this lib. in CRM as a Web resource like this:
Step 2: Create HTML file and Write the angular js code in it. Here i write very simple code.


Step 3: Create HTML Web Resource in your Dynamic CRM and Upload the file that you have created in the last step, as show in below Image.


Step 4: Now apply this Web Resource on any Entity form. Here i applied this on Account Entity.

Step 5: Now reload the page and see the page on which web resource is applied.

Tuesday, December 26, 2017

Deployment of CRM Portal from one CRM Environment to another Environment

Deployment of CRM Portal from one CRM Environment to another has always been a challenging task for everyone. As I have seen many folks were facing many challenges during CRM Portal deployment and finding for best way to migrate CRM Portal Configuration from Development to Test and Test to Production Environment.

CRM Portal provides two ways for Deployment mentioned below :

Website Copy Tool - I was like WAOOO...when i got to know about this tool and i have started using it first time to migrate my CRM Portal Configuration from Development Organisation to UAT , but it disappoint me when i found that this tool has so much limitations like :

• It does not migrate your Subgrid Entity Forms, so you have to manually recreate it on destination organisation which is very annoying and time consuming.

• Along with Subgrid Entity forms, some other configuration you have to create manually like sometimes it does not map correct values in lookup in Entity Forms and Entity List.

• Incremental Deployment is not possible through this tool. Because it does not migrate data based on GUID, Each time when you run this tool either you will need to delete all configuration that you had migrated earlier or need to create new Portal/Websites to keep the Old configuration copy as it. is. otherwise It will create the duplicate records in destination organisation..

ALM Toolkit -  Although CRM Portal Community recommends to go with this tool for CRM Portal Deployment But for me this tool is damn complex and confusing also its very tough to use, Basically this tool is made for Power Shell Expert guys. So here i will not going to use this tool.

Also this was not free tool till few days back but not sure now whether its available for free use or not. Although i am still learning it how much it is feasible to fulfill my requirement, i will get back once i will have the proper understanding of this tool.

So now the question is what approach or tool we should use for CRM Portal Deployment:

Configuration Migration Tool:

Before going to explain this approach i am assuming that you all guys will be having knowledge of Configuration Migration Tool available in CRM SDK, if not please have a look below link first and then do deployment

https://technet.microsoft.com/en-in/library/dn647422.aspx


Configuration Migration Tool (DataMigrationUtility) is one of best tool available in CRM SDK to migrate CRM Portal Configuration from one Environment to another without any limitation.

This tool works great not only if you are planning for only one time deployment but also for Incremental deployment.

This tool exports CRM data by a given schema  to a zip package. The package could be kept as back up or imported to other CRM instances. PackageDeployer tool from sdk “Tools” folder is  a deployment option as well and gives you a chance to deploy solution and portal together. All you need to use the tool is create an export schema once and update by new needs. 

The beauty of this tool is keeping the same ids (guides) across different environments. so it nullify the chance of duplication.

Steps to Deploy CRM Portal Configuration using Configuration Migration Tool :

Create Schema File for CRM Portal :

This is only one time activity, once you will have your Schema File, you will not be required to create it again unless you need to add some other entities.

1.Run the Configuration Migration Tool (You can find this tool in CRM SDK at location \SDK\Tools\ConfigurationMigration\DataMigrationUtility.exe\
2.Choose Create Schema Option from Opened Window and Continue
3.Enter your Organisation's credential and Click Login, Make sure you have selected "Organisation List" Checkbox if you are having multiple organisation setup on same server.
4.After Successfully Log In -  Select ADX Solutions one by one from Solutions Drop-down and add all CRM Portal Entities and its all respective Fields.
5.Make sure you are selecting only CRM Portal Solutions from DropDown and creating Schema File of only CRM Portal related entities (All entities having prefix adx_).
6.Along with CRM Portal Entities, Don't forget to add Note entity because ADX also use CRM's Note entity to attach your webfile attachments (images, CSS etc)
7.Once you are done with Schema File Creation. Save and Export this File and save at your machine.

Export CRM Portal Configuration From Source Organisation :

Once you have your Schema File, You are ready to Export your CRM Portal Data from Source Organisation.

1.Run the Configuration Migration Tool (You can find this tool in CRM SDK at location \SDK\Tools\ConfigurationMigration\DataMigrationUtility.exe\
2.Choose Export Data Option from Opened Window and Continue
3.Enter your Organisation's credential and Click Login, Make sure you have selected "Organisation List" Checkbox if you are having multiple organisation setup on same server.
4.Select the Schema File that you have created earlier in first Lookup
5.Select your Desktop location where you want to keep the exported data file of source CRM Portal Configuration.
6.Continue to Start Exporting the Data


Import CRM Portal Configuration to Destination Organisation :

Once you have your Data.zip file, You are ready to Import your CRM Portal Data in Destination Organisation.

1.Run the Configuration Migration Tool (You can find this tool in CRM SDK at location \SDK\Tools\ConfigurationMigration\DataMigrationUtility.exe\
2.Choose Import Data Option from Opened Window and Continue
3.Enter your Organisation's credential and Click Login, Make sure you have selected "Organisation List" Checkbox if you are having multiple organisation setup on same server.
4.Select the Data.zip File that you have exported earlier.
5.Continue to Start Importing the Data in destination organisation

x

Tuesday, December 19, 2017

CRM Field Editing Ninja

If you need to change some of the field’s behavior such as:
  • Required level
  • Enable/Disable Auditing
  • Flagging the fields to be Searchable or not

Rather than opening the fields 1-by-1 to make the change, there is a shortcut to apply the same settings to more than 1 fields:
CRM_Field_Editing_Ninja
Select the list of fields that require the similar settings, click the Edit action to open the “Edit Multiple Fields” window to apply the changes to these fields

Friday, August 11, 2017

Microsoft Flow – Create record in Dynamics 365

Recently we received a requirement to integrate a mailbox not configured in CRM and external to CRM with Dynamics 365.

The client had an enquiry mailbox, and they did not want the emails to be created in CRM, and therefore it was not configured. However, they did want that the lead should be automatically created for all enquiries received. That is where Microsoft Flow came to the rescue. Using Flow, it is possible to design process flows to automate integrations with external systems.
Here we discuss the steps to create a lead in Dynamics CRM for every email received on a Gmail id.

Steps to create the flow:

1. Go to https://portal.office.com and click the Flow as shown in the screenshot below;
Create record in Dynamics CRM
2. Click on ‘Create from Blank’ button as shown in the screenshot below;
Create record in Dynamics CRM3. Select ‘Gmail – When a new email arrives’, it will then ask you for the Gmail credentials, enter the appropriate credentials.
Create record in Dynamics CRM4. Now select ‘Inbox’ as seen in the screenshot below;
Create record in Dynamics CRM5. Next, click on ‘New step’ button and select ‘Add an action’ as seen in the screenshot below;
Create record in Dynamics CRM6. Then select ‘Dynamics 365 – Create a new record’ as seen in the screenshot below;
Create record in Dynamics CRM
7. Selecting the above option allows us to enter the Organization Name, Entity name of the records we need to create in Dynamics 365 when an email is received, and we can also specify the field mapping as shown below. Once the mapping is done, click on ‘Create Flow’.
Create record in Dynamics CRM
The lead will be created in CRM with this mapped data, and the body of the email is copied to lead notes.
8. Then click on ‘Done’, and the flow is now ready to use.
9. Now whenever we receive an email on Gmail, the lead will be created in CRM. Also, we can see the status in ‘My flows’  list as shown in the screenshot below;
Create record in Dynamics CRM

Conclusion:

Using Microsoft Flow, users can easily create and automate workflows across multiple applications, in this case, Gmail & Dynamics 365. Once a flow is configured, it can be managed on desktop or mobile device and gives users an unprecedented ability to automate.

Saturday, August 5, 2017

Field Validation Editable Grids

Scenario

Say I want to get the value of an editable grid cell on change and add some validation on it.
I have a field called ‘Contact Code’ and I want to be notified if I enter a value that is less than 4 characters.
field-validation-editable-grids
We need a way to reference the current field that was entered and validate its value.

getFormContext Method (Introduced in Dynamics 365)

The key is to pass the context object a parameter to the OnChange grid event and then use the getFormContext method to return the reference of the grid.
The handy thing about this is that it can return a reference to either a Form or Grid control depending on where it was called.
function EditableGridFieldValidation(executionContext) {

    var gridObject = executionContext.getFormContext().data.entity;
    var contactCodeValue = gridObject.attributes.getByName('new_contactcode').getValue();
    var contactCodeField = gridObject.attributes.getByName('new_contactcode').controls.getByIndex(0);

    if (contactCodeValue.length < 4) {

        contactCodeField.setNotification('Contact code cannot be less than 4 characters', 'ValidationAlert');
    }
    else {

        contactCodeField.clearNotification('ValidationAlert');
    }
}
Once you have created your code, you can upload your grid control (either on form, subgrid or homepage) by navigating to the Events tab.
Upload your script under Form Libraries like you normally do.
field-validation-editable-grids-3

Under Event Handlers, specify your Entity, Field and select ‘OnChange’ for the Event.
Effectively, you are going to call a function for the OnChange event that performs the field validation.
Click on Add to add your Jscript library and enter the name of the Function.
field-validation-editable-grids-4
Click on ‘Pass execution context as first parameter’ and hit OK. This will pass the executionContext object to the function.
field-validation-editable-grids-5

Publish your changes and you will see it in action !
So there it is, you can do basic string validation for editable grids using the new getFormContext method

Friday, August 4, 2017

Show Hide Sections in Dynamics CRM

/************************************************
stateSectionsOnChange - function to handle which fields
to show based on the state selected
************************************************/
function stateSectionsOnChange() {
    var closeTab = Xrm.Page.ui.tabs.get("Professional Info");
var showTXSection = false;
    var showOHSection = false;
    var showINSection = false;

    switch (Xrm.Page.getAttribute("col_addressstate").getText()) {
        case "Texas":
showTXSection = true;
            showOHSection = false;
showINSection = false;
            break;
        case "Ohio":
showTXSection = false;
            showOHSection = true;
showINSection = false;
            break;
        case "Indiana":
showTXSection = false;
            showOHSection = false;
showINSection = true;
            break;
    }

    closeTab.sections.get("Texas").setVisible(showTXSection);
    closeTab.sections.get("Ohio").setVisible(showOHSection);
    closeTab.sections.get("Indiana").setVisible(showINSection);
}
/***    end stateSectionsOnChange     ***/

Tuesday, August 1, 2017

Configure View Columns for Global Search

Recently, I was asked to change the "View Columns" on CRM Global Search. Typically, there is no seperate view for Global Search. It works on Quick find view of the configured entities for Global search, where it looks for "Find Columns" to run its quick find searches. So, I started looking into Quick find view. After little bit research, I found Global Search shows first three columns of Quick Find view in the searches. So I just changed the order of the few columns, moved the requested View Columns to first three and Voila! its done. 

Convert Plugin to Sandbox mode,

While working with Dynamics CRM Plugins, the thumb rule for Plugin Registration is:
  • If you are working with CRM On-Premise, use Plugin isolation mode as None.
  • If you are working with CRM Online, use Plugin isolation mode as Sandbox.
So, now the scenario is you are working on big implementation for CRM On Premise. Now your organization decides to move to CRM Online. The first task comes to mind is to move all the Plugins to Sandbox mode and see if they are still working considering running Plugin in sandbox comes with some limitations (such as you cannot access file system/registries/external assemblies/protocols/IP Addresses etc).

To convert the Plugin assemblies to Sandbox mode, one option is to open Plugin Registration tool and convert the assemblies one by one which is a tedious task. The other simple option is do this by Customization.xml file. Below are the steps how to do that.
  1. Create a solution with all Plugin assemblies or use existing solution if already available.
  2. Export the solution.
  3. Unzip the solution and extract all the files.
  4. Open Customization.xml file with notepad/Xml editor/Visual Studio.
  5. Look for IsolationMode tag.
  6. Update the IsolationMode property to for all the PluginsBasically the xml should look like below:<IsolationMode>2</IsolationMode>
  7. Save the Customization.xml file.
  8. Zip all the files back and import to CRM.
This way you can quickly sandbox your plugin or in other terms all the plugin would be converted/upgraded to Sandbox mode.       

Data Import Security Role for Dynamics CRM

Recently, someone asked on one of the community forum that what all privileges should be given to allow Data Import to Dynamics CRM. I responded but thought that it would be helpful if I write in one of the blog so that it benefits others as well.
If we think of import process to CRM, it works as below:
  1. Source file gets uploaded.
  2. It will prompt for data mapping.
  3. Data Map record gets created and you can start seeing the status for the file being imported under Settings-->Import.
  4. Data gets imported and records created.
So broadly if someone want to import the records, he definitely should have Create, Read and Write permission on the entity, he wants to import. Along with that he should have privileges on following entities:
 Entity Security Role Tab Privilege
 Import Source File Core RecordsUser Level  Create, Read, Write, Delete, Append, Append To
 Data Import Core Records User Level  Create, Read, Write, Delete, Append, Append To
 Data Map Core Records User Level  Create, Read, Write, Delete, Append, Append To

Saturday, July 29, 2017

DYNAMICS 365 - HOW TO KEEP YOUR CUSTOMERS UPDATED WITH THEIR CASES


One of the keys to increase the usability of the interaction with your customers, and to adopt your system, is to notify you customers with your Dynamics users updates on a case.

A tip of doing this, is to set a workflow to be triggered when a note is created on a case, the workflow will send an email to the customer, updating him/her with the note description.

You can do this by following the below steps,

1. Create workflow to run on Note entity

2. in the workflow, add a condition to check if the note is regarding a case.

3. If the condition is met, then send email to the customer and place the note description in the email.


4. Save and activate the workflow.


Thanks :)

Monday, July 24, 2017

Business Rules Vs Rollup Fields Vs Calculated Fields


FeatureTriggerExecutionClient / ServerScopeConditionsFieldsFunctionsLimitsUsage
Business Rules

OnLoad
On Change
Synchrounous / Real Time
Execution order:
First: System JavaScripts
Then: Custom Javascript  
Finally: Business Rules
Client: Specific Forms/ All Forms/
Server
Entity / All Forms / Specific FormsAnd / OR, not a mixureAll Fields on the form body
  • Show Error Message
  • Set Field
  • Set Business Required
  • Set Visibility
  • Set Default Value
  • Lock / Unlock Field
Fields updated through Business Rules do not trigger the fields on change event of JavaScript. Reducing potential of infinite loop.Perform field validations and apply field logic to improve user input and experience
Rollup FieldsOn Save / Every 1-12 hours / When User Presses Rollup Refresh ButtonAsynchronous / Every 1-12 hours
Rollups are calculated by scheduled system jobs Settings > System Jobs > View > Recurring System Jobs. System Job type: Mass Calculate Rollup Field or Calculate Rollup Field
ServerRelated Entity / Parent Child Relationship Upto 1 Level DeepAnd / OR, not a mixureWhole Number
Decimal
Currency
Date
SUM / MAX / MIN / COUNT / AVGCannot use other Calculated or Rollup fields as part of a rollup.Aggregate calculations of child entities. The difference between Calculated Fields is Rollup fields are not virtual, they are physical attributes. Such as no. of open opportunities, activities, revenue, etc.
Calculated Fields

OnSaveSynchronousServerEntity/ Parent Child Relationship Upto1 Level DeepAND or OR , Not a mix of both
  • Single line of text
  • Option Set
  • Two Options
  • Whole Number
  • Decimal Number
  • Currency
  • Date and Time
ADDHOURS, 
ADDDAYS,
 ADDWEEKS,
ADDMONTHS,
ADDYEARS,
SUBTRACTHOURS,
SUBTRACTDAYS,
SUBTRACTWEEKS, 
SUBTRACTMONTHS,
SUBTRACTYEARS,
DIFFINDAYS, 
DIFFINHOURS,
DIFFINMINUTES,
DIFFINMONTHS,
DIFFINWEEKS,
DIFFINYEARS,
CONCAT,
TRIMLEFT, and TRIMRIGHT.
Two calculated fields cannot reference each other in their formulas
Floating point numbers cannot be used in calculated fields.
Won’t trigger workflow updates
Fields are virtual /not stored at the database level
Ability to populate a field with simple calculations based on other values and conditions on the form in a real time manner.   This alleviates the need for JavaScript in fairly straight forward scenarios such as adding days or months to a date, or adding or subtracting fields on the same entity.
Calculated fields can calculate based on other fields, including rollup fields and other calculated fields.

Sunday, July 16, 2017

Multi-Select Option Set in Dynamics 365

A new feature "Multi-Select Option Set" is introduced in Dynamics 365. Very useful feature, it will reduce lot of effort for the developers. In one of our project we used an external IP to implement this. Few screen shots on this awesome feature.











Sunday, July 9, 2017

RETRIEVE OPTIONS LIST IN MULTIPLE LANGUAGES in DYNAMICS 365

If you had a requirement where you want to retrieve a list of options of an option set in your CRM/365 organization depending on the language, for example if you pass to the method 1025 it will return the options in Arabic, if you pass 1033 it will return the options in English and so on.

For example, if you are integrating your Dynamics 365 with a portal, and you want to create a drop down list of these options coming from an option set in the 365, and this options maybe changed in the future, so its not practical to change the drop down list options.

In this case, I'm going to give you a code I was using to listing data from CRM 2016 to SharePoint 2016.

public Dictionary<int, string> LocalOptionSetList(String entityName, String optionSetName, int lcid)
        {
            try
            {
                if (lcid == 0)
                    lcid = 1033;// default english
                using (var xrmContext = new XrmServiceContext(CRMConnection.CRM))
                {
                    RetrieveAttributeRequest raRequest = new RetrieveAttributeRequest
                    {
                        EntityLogicalName = entityName,
                        LogicalName = optionSetName,
                        RetrieveAsIfPublished = true
                    };
                    RetrieveAttributeResponse raResponse = (RetrieveAttributeResponse)xrmContext.Execute(raRequest);
                    PicklistAttributeMetadata paMetadata = (PicklistAttributeMetadata)raResponse.AttributeMetadata;
                    OptionMetadata[] optionList = paMetadata.OptionSet.Options.ToArray();
                    Dictionary<int, string> dic = new Dictionary<int, string>();
                    foreach (OptionMetadata oMD in optionList)
                    {
                        dic.Add((int)oMD.Value, oMD.Label.LocalizedLabels.Where(x => x.LanguageCode == lcid).FirstOrDefault().Label.ToString());
                    }
                    return dic;
                    //StatusAttributeMetadata message if you want  to retrieve options from a status reason field
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }

Get files of last hour in Azure Data Factory

  Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...