Monday, 28 October 2013

How to Call a HTML web resource from a Java script

Create  a Java script 

function showstatus()
alert("hi hw r u");
 var WinSettings = "center:yes;resizable:no;dialogHeight:300px;dialogWidth:650px";
window.showModalDialog("../WebResources/new_show.html", null, WinSettings);


Create a HTML web resource with name show.html :
In Html web resource we can call any entity using soap or o data query .

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta charset="utf-8"></head><body onload="getAllData();"> 
   <title>CRM 2011 HTML Web Resource </title> 
   <!-- including the 'ClientGlobalContext.js.asp'      -- which gives the context information--> 
   <script src="ClientGlobalContext.js.aspx">     </script>   
  <!-- including the minified version of jquery-->   
 <!--script type="text/javascript" src="new_jquery_1.4.1.min.js"--> 
    <script language="javascript">       
 function getAllData()
 {             var serverUrl;           
 var ODataPath;            
var userid;            
var userRole;         
   var OrgName;        
    var context = GetGlobalContext();          
  serverUrl = context.getServerUrl();           
 ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";  
          userid = context.getUserId();            
   userRole = context.getUserRoles();         
   OrgName = context.getOrgUniqueName();     
       Text1.Title = serverUrl;          
  Text2.Title = userid;            
Text3.Title = userRole;           
 Text4.Title = OrgName;          
  Text1.value = serverUrl;         
   Text2.value = userid;          
  Text3.value = userRole;         
   Text4.value = OrgName;       
<input id="Text1" type="text"></p>  
  <p>User ID &nbsp;      
  <input id="Text2" type="text"></p>   
 <p>User Role &nbsp;       
 <input id="Text3" type="text"></p> 
   <p>Oraganization &nbsp;         
<input id="Text4" type="text"></p>


One can also update any entity using java script:
In Account form invoking a Html webpage and taking input from user and updating in CRM

var WinSettings = "center:yes;resizable:no;dialogHeight:300px;dialogWidth:650px"
    var clientInformation = window.showModalDialog("../WebResources/lbg_Contact_Client_Address", GuidArgs, WinSettings);

Monday, 21 October 2013

Java Script Ms Crm 2013

The Xrm.Utility library in Dynamics CRM 2013 provides new functions to display alerts and confirmations in CRM forms. In previous versions of CRM, you would have to use the alert() and confirm() JavaScript functions, but these are now supported in the CRM 2013 SDK with some additional options.


This function takes in two parameters:

message: The message you wish to display in the alert.

onCloseCallBack: A function to execute when the user clicks on OK or closes the alert window using the X button.


The following code will display an alert and then will set the field of a Contact to ” when the user clicks on OK.


showAlert = function ()


    Xrm.Utility.alertDialog("This will set the First Name to , function ()

        Xrm.Page.getAttribute("schema name of filed").setValue("value");




This function takes in three parameters:

message: The message you wish to display in the alert.

yesCloseCallback: A function to execute when the user clicks on Yes.

noCloseCallback: A function to execute when the user clicks on Cancel.


The following code will prompt the user to confirm if they want to save the form. If they select Yes, the form will save. If they select Cancel, the Email Address field will have focus set.

showConfirmation = function ()

    Xrm.Utility.confirmDialog("Are you sure you want to save this record?",

        function () {



        function () {

            Xrm.Page.getControl("schema name").setFocus();



Sunday, 20 October 2013

Deletion Service in MSCRM 2011

Deletion service under CRM 4.0
All deleted records or entities under CRM 4.0 will not be directly deleted. Instead CRM will mark the objects in first step as “marked for deletion”.  As a result, the marked objects could no longer be accessed by the web application or through SDK web service calls. This is called as “soft delete” and will be implemented by changing the objects attribute DeletionStateCode to status 2.
If the DeletionStateCode of an object is set to 2, the object will be filtered out from all standard data views in the web application and is also not accessible through access via SDK web service calls.

Deletion service under CRM 2011
With CRM 2011 the deletion of objects will change from “soft delete” to “hard delete”. We now no longer use Deletion State Codes for marking objects. Instead objects will be deleted immediately. This helps to improve performance and also reduces complexity in case of filtered views or tables.

But in Crm 2011 now we have DeletionService Async Maintenance
To provide some context from CRM 4.0, the DeletionService performed physical data cleanup on records that had been logically deleted through the application by setting the DeletionStateCode = ‘2’.  This behavior no longer occurs in CRM 2011 – when records are deleted through the application, they are physically deleted from the database.  So, why the need for a DeletionService maintenance operation?
The database maintenance performed by the DeletionService operation focuses both on organization-wide cleanup and record-specific cleanup.  For the latter cleanup to be performed it’s important to note that during the initial delete action while records are removed from the entity tables, they are also inserted to the dbo.SubscriptionTrackingDeletedObject table.  This table provides the DeletionService with specific ObjectId’s that have been removed so that further cleanup can be performed asynchronously.

Now how to handle the requirement if customer want to recover the deleted record.
On click of delete button either Deactivate record on fire of java script or plugin or change custom id action and assign to some team.
later on write asynchronous plugin or work flow to clean the record from system after some period of time.

Thursday, 17 October 2013

CRM 2011 outlook synchronization process

The CRM/Outlook synchronization process can occur in one of two ways:  1) manually clicking the "Synchronize with CRM" option, or 2) scheduled background synchronization.  The actual CRM/Outlook sync process looks like this when kicked off:
  1. Prepare sync is called to query the server to prepare all the entities which should be synchronized down from the CRM server.  There are a variety of tables used within the MSCRM database during this process:
    1. Subscription table = Specifies the SyncEntryTable name for each user that has been created.  There is a separate SyncEntry table for the outlook sync and the offline sync for each user.  A SubscriptionType of 0 = Offline and a SubscriptionType of 1 = Outlook.  You'll notice that a SubscriptionType of 2 for Address Book Provider will show as well.  The ABP SyncEntry table is no longer used.  The ABP sync is now handled exclusively by the Outlook MAPI sync.  Each SubscriptionId is tied to a unique SyncEntryTableName.
    2. SubscriptionClients table = Specifies which of the end user's machines is set to be the synchronizing client (based off of the IsPrimaryClient column).
    3. SubscriptionSyncInfo table = Specifies the sync metrics for each SubscriptionId (ex. StartTime, DataSize, InsertObjectCount, etc.).
    4. SyncEntry_<guid> = Specifies object being synchronized, the ObjectTypeCode (which tells you the entity), and the state of the sync.  Remember, there is a separate Sync_Entry table for each sync process per user
  2. After the information is prepared on the server end, it returns xml to the client with the number of records to be synchronized for each action type (create/update/delete) for each entity type (contact, appointment, etc).
  3. The CRM Outlook client then makes another sdk call, GetSyncData, according to the xml returned by the prepare sync to get the crmid and change timestamp for each changed record.  This information is then added to the OutlookSyncTable table in the OutlookSyncCache.sdf file.  This file is located at the following location on a Win7 machine:  C:\users\<user name>\AppData\Roaming\Microsoft\MSCRM\Client).
  4. The client also tracks the Outlook item changes and adds them to the OutlookSyncTable table in the .sdf file.  Now this table should contain all of the changed record information which comes from both CRM server and Outlook.
  5. The sync process will then process each changed record in the OutlookSyncTable table according to the change type and change timestamp.  For example, if the change type from crm server is create and there is no change from the outlook client, the action will be to create an item in Outlook.
  6. When one record is synced successfully, the entry in the OutlookSyncTable table will be removed and the IdMappingTable table entry will be inserted/updated/deleted accordingly. The IdMappingTable table contains the mapping between crmid and Outlook entryid.  When a crm record is synced down to Outlook, the table will help to find the corresponding Outlook item.  The only exception to the IdMappingTable table is for appointments where we cannot find an id mapping.  In that scenario, a search for an appointment with the same global object id will be done in Outlook. That is the only time that a search will be done in Outlook.
  7. If one entity fails and is not synchronized, then the corresponding entry in the OutlookSyncTable table will stay.  The next time a synchronization takes place, this entry will be synced again unless the user chooses to ignore the error (Select the “Ignore all errors” checkbox in the sync dialog in Outlook).

Friday, 11 October 2013

Upgrade from CRM 4.0 to MSCRM 2011

Hi All MS CRM lovers a blog dedicated to all to simplify the understanding on Upgrade from MS CRM 4.0 or earlier version to MS CRM 2011.


  1. Microsoft Dynamics CRM 2011  and SQL Server available in 64-bit editions.
  2. So ,simple upgrade on the same computer is not possible for installations of 32-bit editions of Microsoft Dynamics CRM 4.0.
Upgrade Considerations
  1. Only Microsoft Dynamics CRM 4.0 can be upgraded to Microsoft Dynamics CRM 2011.
  2. Earlier versions, such as Microsoft Dynamics CRM 3.0, must first be upgraded to Microsoft Dynamics CRM 4.0 and then upgraded to MicrosoftDynamics CRM 2011.
Upgrade Path

  1. Migration
  2. Connect  to Existing
  3. In- Place Upgrade

  1. CRM SQL SERVER : 64 bit only  (SQL SERVER 2008 R2)
  2. CRM server:64 bit only (Windows Server 2008 R2)  
Upgrade Preparation :

  1. Upgrade Sql server to Sql2008  R2 64 bit
  2. Outlook Client plan to be on latest UR7
  3. Verify we have latest Software and licensee.
  4. Verify Latest Disaster Recovery  for Roll Back
  5. Validate third party Customization
  6. Finalize plan ( Check List)
  7. Production Upgrade.
  8. Must Upgrade from CRM 4.0 to CRM 2011
 The best way to upgrade is as follows:-
1) Take SQL backup of MS CRM4 .
2) Create a Database in MS CRM 2011 SQL Server. Overwrite it or restore the backup of MS CRM 4 on it.
3) Now open Deployment Manager. Click create Import
4) Now select database server name and your new database on which you have uploaded the backup of MS CRM 4(STEP 2) and enter your report server name.
5) After finishing, check for all customizations, JS ,
Plugins, Workflows ISVs that are they imported.
6) New ISV pages gets added as new tab and JS as new libraries in MS CRM 2011.


I think it would give a very good picture of upgrading  to CRM 2011,in next blog i will try to cover the post upgrade activities which involve handling the java script , plugin and ISV component.