Monday, July 27, 2015

Microsoft Platform Ready Test Tool

The Microsoft Platform Ready Test Tools (MPR Test Tools) are designed to help you verify your application’s platform readiness. The MPR Test Tools are wizard style complete self-test tools designed to guide you through the entire test process.  The MPR Test Tools allows you to test your application against the following platforms and technologies which are competency eligible (other technologies are included, but not supported):
·          Windows Azure
·          Microsoft SQL Server 2012
·          Microsoft Exchange Server 2013 · Microsoft Exchange Online v.2 · Microsoft Lync 2013 · Microsoft Lync Online v.2
·          Microsoft SharePoint Server 2013
·          Microsoft SharePoint Online
·          Windows Server 2012
·          Windows Server 2012 R2
·          Microsoft Dynamics CRM 2013

Step 1: Download Microsoft Platform Ready Test Tool from:
SignUp with Microsoft Credentials and download the tool from below “Download” link;








Step 2: Install “MPR Dynamics CRM 2013 Test Tool v4.4.7 – InstallShield Wizard”
             

Step 3:  Once installation get completed, open MPR Dynamics CRM 2013 Test Tool v4.4.7 and “Start New Test” as per the screen shot below,
    

Step 4: Give the name for your test and click Next,


Step 5: Before starting the test, we need to validate all the pre-requisites defined for the MPR test, for Microsoft Dynamic CRM we need to give the Organization details with UserName and Password of Microsoft Account;

                                 

Step 6: Give the organization and Microsoft Account details and validate it;
                                 

Step 7: Next is Setup Information, if you want to test solution package then check “Yes” option and add the Managed solution in the Setup File(s);
                         

Step 8: Next step is Publisher Information which we can get it from CRM organization and enter the publisher details and validate it;
                                   

Step 9: Once all the pre-requisites (check Prerequisite status) get passed for Microsoft Dynamic CRM 2013 click Next;
                                   

Step 10: Now you are in stage of “Execute Test”, there are 3 steps included in it stated: Application Installation, Scripting Usage and Application Uninstall.
Check “Yes” in every steps and validate it, once you click on Validate it will ask for credentials to log on to the CRM organization, provide “System Administrator” credentials and perform the test as given below.
                                 


Step 11: Once all the execution steps completed you can export the report of MPR test from the path given below;
*****************\MPR\Test Results
Troubleshooting Steps to take care:

  1. Always restart the server once you install MPR test tool, otherwise it will get failed during prerequisites step.
  2. Always used Managed Solution to perform MPR test.
  3. Before performing the test, manually perform install and uninstall solution in your organization and note down time taken for installation and uninstall, it should exceed 15mins for installation and 30mins for uninstall, if exceeds then perform necessary steps to make it compatible for MPR test.
  4. Before performing MPR test make it clear that all the pre-required solutions are being installed on CRM organization.
  5. The solution being test for MPR test should not be pre-installed in CRM organization.
  6. Based on the platform being evaluated, the MPR Test tool will require: 
  • Operating System: Windows 8.1 or Windows Server 2012 R2
  • Application Environment: Microsoft .Net 4.0 Framework, PowerShell 3.0 or above.



Thursday, July 17, 2014

Disable / Enable form fields through JavaScript

There are many scenarios where we need to disable all fields/controls on an Entity form. Here I am showing different ways to handle it through JavaScript.

function disableFields() {
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes) {
Xrm.Page.getControl(attributes[i].getName()).setDisabled(true);
Xrm.Page.getControl(“statuscode”).setDisabled(false);
}
}
function enableFields(){
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes){
Xrm.Page.getControl(attributes[i].getName()).setDisabled(false);
}
}

  • Enable / Disable a field

Xrm.Page.getControl(“fieldname”).setDisabled(false);

  • Enable / Disable a Section

function sectiondisable (sectionname, disablestatus)
{
var ctrlName = Xrm.Page.ui.controls.get();
for(var i in ctrlName) {
var ctrl = ctrlName[i];
var ctrlSection = ctrl.getParent().getName();
if (ctrlSection == sectionname) {
ctrl.setDisabled(disablestatus);
}
}

  • Enable / Disable a Tab

function tabdisable (tabname, disablestatus)
{
          var tab = Xrm.Page.ui.tabs.get(tabname);
 if (tab == null)
alert("Error: The tab: " + tabname + " is not on the form");
 else {
     var tabsections =  tab.sections.get();
     for (var i in tabsections) {
     var secname = tabsections[i].getName();
     sectiondisable(secname, disablestatus);
              }
                 }
}


Wednesday, July 16, 2014

Secure Vs. Unsecure Configuration

How to pass parameters to plug in
Secured vs. Unsecured
Below are key differentiation between Secured and Unsecured data configuration
  • Access
  1.   Data passed through “Unsecure” section is PUBLIC (i.e., It can be read by any user in CRM).
  2. Only users with “System Administrator” role have access to the data passed through “Secure” configuration section
  • Storage
  1. “Unsecure” config data will be stored along with the Plugin ‘Step’ registration information (i.e., In SdkMessageProcessingStep entity)
  2. “Secure” config data will be stored in a separate entity named “SdkMessageProcessingStepSecureConfig
  3. Only “System Administrator” has Read access on this entity, hence only users with ‘Sys Admin’ role can access this data
  4. Both “Secured & Unsecured” configuration data stored as “Plain text” in DB
  • Outlook Sync
  1. “Unsecured” configuration data is downloaded to the user’s computer when they go offline making it Unsecure
  2. “Secured” configuration data is NOT downloaded to User’s Computer when they go Offline
   
       How to read Configuration data in Plug-in
  1. When we register plug-in step, there is a field when we can specify some configuration parameters for the plugin execution as below:

  2. Then in constructor of plugin class we will get the configuration value which we can use later in the execution method:

In quick watch we can check all the configuration parameters as below:

  • ·          Note :- If you want to read “Secure” configuration in the plug-in code, either change the  user context in plugin registration as “CRM administrator ” or Impersonate to “CRM Administrator” role user in the code.

Plug in pipeline execution

Plug in pipeline execution

Event Execution Pipeline Stages

The event pipeline is divided into multiple stages, of which 4 are available to register custom developed or 3rd party plug-ins. Multiple plug-ins that are registered in each stage can be further be ordered (ranked) within that stage during plug-in registration.

Event
Stage name
Stage number
Description
Pre-Event
Pre-validation
10
Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage may execute outside the database transaction.
The pre-validation stage occurs prior to security checks being performed to verify the calling or logged on user has the correct permissions to perform the intended operation.
Pre-Event
Pre-operation
20
Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage are executed within the database transaction.
Platform Core Operation
MainOperation
30
In-transaction main operation of the system, such as create, update, delete, and so on. No custom plug-ins can be registered in this stage. For internal use only.
Post-Event
Post-operation
40
Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage are executed within the database transaction.
Post-Event
Post-operation (Deprecated)
50
Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage may execute outside the database transaction. This stage only supports Microsoft Dynamics CRM 4.0 based plug-ins


Plug-in Assembly Isolation mode and Storage Component

Plug-in Isolation mode

There are 2 isolation mode available in CRM 2011,

Sandbox : Supported for Microsoft Dynamic CRM Online
None: Supported for CRM 2011 on-premises

Storage Component:

There are 3 storage options available in MS CRM 2011 for deploying assembly,
  •              Database
  •               Disk
  •               GAC
  • Database:-
The assembly dll is stored in the database, rather than the file system. The major advantages are that the assembly need only be deployed once if you have multiple CRM servers, and that no additional action is required to restore / redeploy the assembly either during disaster recovery, or if redeploying to an alternate server. This is the preferred option in production environment.
  • Disk:-
The assembly dll is placed in the \server\bin\assembly directory on each server. You have to ensure the dll is placed in correct place on all CRM servers, so the deployment overhead is a little greater. I normally use this option in development environments as you can redeploy newer versions solely by file transfer rather than re registering. Also, if debugging the assembly, .pdb file needs to be placed in same location, with this option it’s easy to ensure the dll and pdb are from the same build.
  • GAC:-
The assembly is placed in the Global Assembly Cache on each CRM server. The GAC does allow multiple versions of an assembly, but CRM doesn't. So you don’t really gain anything by using GAC.

Note: - There is one further consideration, if your plugin assembly has other dependent assemblies, then you can place this dependent assembly in the GAC whichever of the above options is used. However, if you use the Disk option, then the dependent assemblies can also be deployed into the \server\bin\assembly directory.



Plug-in Images

Plug-in Images
Images are snapshots of the entity’s attributes, before and after the core system operation. Following table shows when in the event pipeline different images are available:
Message
Stage
Pre-Image
Post-Image
Create
PRE
No
No
Create
POST
Yes
Yes
Update
PRE
Yes
No
Update
POST
Yes
Yes
Delete
PRE
Yes
No
Delete
POST
Yes
No
The benefits of images
One of the best uses for this is in update plug-ins. As mentioned before, update plug-in target entity only contains the updated attributes. However, often the plug-in will require information from other attributes as well. Instead of issuing a retrieve, the best practice is to push the required data in an image instead.
Comparison of data before and after. This allows for various audit-type plugins, that logs what the value was before and after, or calculating the time spent in a stage or status.
PreEntityImages :
It is basically used to capture the data when the form loads. That is the data which is present by default when the form loads.  The syntax for using the PreEntityImages in CRM 2011 is changed as compared to CRM 4.0. Remember the PreEntityImages cannot be registered for “create” operation.
Syntax Used in CRM 2011 :
Suppose you registered the Plugin and added a Image with name “PreImage 
Entity preMessageImage;
if (context.PreEntityImages.Contains(“PreImage”) && context.PreEntityImages["PreImage"] is Entity)
{
preMessageImage = (Entity)context.PreEntityImages["PreImage"];
accountnumber = (String)preMessageImage.Attributes["accountnumber"];
}
Here Entity is an Class that is available in the Microsoft.Crm.Sdk.dll
PostEntityImages :
The Post Image contains the attributes value which are finally changed. We can capture the changed data before the database operation takes place. And can do any kind of validation based on the changed data. Remember it can only be registered  for update message and cannot be registered on create message.
Syntax Used in CRM 2011 :
Suppose you registered the Plugin and added a Image with name “PostImage 
Entity postMessageImage;
if (context.PostEntityImages.Contains(“PostImage”) && context.PostEntityImages["PostImage"] is Entity)
{
postMessageImage = (Entity)context.PostEntityImages["PostImage"];
accountnumber = (String)postMessageImage.Attributes["accountnumber"];
}

The PreEntityImages and PostEntityImages are Very useful in Scenarios where we want to compare the data that is changed by the user. Based on the changes the custom operation can be performed.

Find & Advance Find Search

Find perform a search on an attribute for which it is defined.

Advanced Find perform search on the conditions and the attributes for which user customizes or runs it.

Normal Find in faster as it looks for one attributes and matches with that and returns the result whereas Advanced Find searches for all the attributes and conditions while parsing through the records.

Find is applicable on only active records and it finds only on 2 or 3 column which we have defined in the find view and even it returns any those column which is there in the view but advanced find is applicable to all the records and it finds all the columns and even it returns all the column and filter criteria can be on any column.

Find is faster than Advanced Find.