Monday, January 23, 2012

Early Bind in CRM 2011


When you're working with Dynamics CRM 2011 and you need to write plug-ins or other kinds of integration with .NET code you should make use of early binding. This gives you a context that contains a typed .NET representation of all your entities, relations...

Account entity = new Account ();
entity ["name"] = "My Account"; //loosely typed, late binding
entity.AccountNumber = "1234"; //strongly typed, early binding

Advantages of Early Binding are
1) You no longer have to work with magic strings when accessing attributes
2) Every property is typed the correct way. No need to cast attributes values anymore.
3) When entities or attributes are removed, renamed ... and you update your context your code   won't    build and you can fix each problem immediately. No more runtime errors.
4) Less bugs
5)  Less manual work

Run the CrmSvcUtil.exe tool, with the Microsoft.Xrm.Client.CodeGeneration extension, to generate your entity classes and service contexts. The following is an example command to create a file called Xrm.cs that points at an instance of Microsoft Dynamics CRM. Note that the Microsoft.Xrm.Client.CodeGeneration.dll file must be in the same directory as the CrmSvcUtil.exe file, or in the system GAC, when you run this command.

Download the CRM 2011 SDK to get Microsoft.Xrm.Client.CodeGeneration.dll and CrmSvcUtil.exe tool

Here are the steps to create early binding

1)      Open the Command Prompt 
2)      Navigate to the SDK folder \sdk\bin
3)      Run the command given below by changing the server name and organization name to your crm server name and organization name for which you want to create the early binding
CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization,          Microsoft.Xrm.Client.CodeGeneration" /out:Xrm.cs /url:http://CRMSERVERNAME/Organization NAME/XRMServices/2011/Organization.svc /domain:CONTOSO  /username:administrator /password:pass@word1 /namespace:Xrm /serviceContextName:XrmServiceContext
 
 

It will create a xrm.cs file in your /sdk/bin  folder 


Wednesday, January 11, 2012

Pre-Image & Post Image in CRM plugin

Plugins in Dynamics CRM, allow you to register images against the steps of a plugin assembly. Images are a way to pass the image of the record that is currently being worked upon prior or after the action has been performed. In general it could be said, it is the image of the record as is available in the SQL backend.

Two types of Images are supported, Pre-Image and Post Image.

In case of Pre-image, you get the image of the record as is stored in the SQL database before the CRM Platform action has been performed.
Post Image, returns the image of the record after the CRM Platform action has been performed.

The following table explains the Pre-Image Availability

The following table explains the Post-Image Availability
  

Monday, January 9, 2012

Customer Care Accelerator (CCA)

image


Microsoft Dynamics CRM 4.0

Microsoft Dynamics CRM 4.0, along with Microsoft® Windows Server® 2003 or Windows Server 2008, is the primary software prerequisite for installing the software that supports integrated agent desktop development and deployment.
The Microsoft Dynamics CRM server acts as the configuration store and administrative system for agent desktop projects that you create using User Interface Integration (UII)-based technologies.


User Interface Integration (UII)

UII is a set of client-side binaries that support the core functions involved in creating an integrated agent desktop solution. It includes the following:
·         The core desktop compositing engine. These are the binaries that enable you to design an integrated agent desktop shell.
·         The Application Integration Framework (AIF). AIF enables hosting of applications within the agent desktop shell and provides a mechanism for sharing information between those applications.
·         Hosted Application Toolkit (HAT) and Microsoft Visual Studio® tools. HAT is a Visual Studio guidance packages that enables you to quickly automate applications that you want to host in your agent desktop shell. Another Visual Studio tool is a template you can use to create an integrated agent desktop solution.

Customer Care Accelerator (CCA)

CCA is an integrated agent desktop reference implementation and sample application built by using UII.

Integrated Contact Center (ICC)

ICC is a Microsoft Consulting Services (MCS) solution offering for the customer care and contact center market






Friday, January 6, 2012

Canceling the Save operation in CRM 2011



Method 1:

Add an OnSave event to the form:


Note: The pass execution context as first parameter checkbox is very important to this process. Without it, it will not work.

Inside the Contact_main_library.js web resource, we’ll add the following function:
function Form_onsave(executionObj)
{
var shouldSave = true;

if (shouldSave)
{
alert("Unable to save because of some reason or the other.");

executionObj.getEventArgs().preventDefault();
}
}
Inside the OnSave function, we need to have some type of test to see if we should allow the record to be saved.
For this demonstration, we simply check the value of a variable called shouldSave. If true, then we display an error message to the user then execute the preventDefault() method which will instruct CRM to cancel the save operation.

Method 2:
Add an OnSave event to the form:
//if event.Mode is one means Save, event .Mode is two means Save&Close.
if(event.Mode == 1 || event.Mode ==2)
{
event.returnValue = false;
return false;
}

Reference :-
Gangs036-MS-CRM-Blogspot: Canceling the Save operation in CRM 2011

calculation of duration between two days in crm2011

to calculate duration

// get both dates from the form....
function Testing()
{
var start = Xrm.Page.getAttribute("new_staredate").getValue();
var end = Xrm.Page.getAttribute("new_enddate").getValue();

// to cancel the error when undefined
if (start==undefined || start==null || end==undefined || end==null) {
return;
}

// Get 1 day
var day=1000*60*60*24;
// Get time in days...
var time = ((end-start)/day)+1;

// Can't be less than 0.
if (time<0) time=0;
// Set the duration
Xrm.Page.getAttribute("new_noofdays").setValue(time);
}

Reference :-
Gangs036-MS-CRM-Blogspot: calculation of duration between two days in crm201...

calculation of duration between two days in crm4.0 using javascript


// to calculate duration

// get both dates from the form....
var start = crmForm.all.activeon.DataValue;
var end = crmForm.all.expireson.DataValue;

// to cancel the error when undefined
if (start==undefined || start==null || end==undefined || end==null) {
return;
}

// Get 1 day
var day=1000*60*60*24;
// Get time in days...
var time = ((end-start)/day)+1;

// Can't be less than 0.
if (time<0) time=0;
// Set the duration
crmForm.all.new_duration1.DataValue = time;

Reference :-
Gangs036-MS-CRM-Blogspot: calculation of duration between two days in crm4.0...: