Saturday, November 5, 2011

JavaScript for Disabling a field once its contains a value in crm 2011

 Write this javascript in onload event of a form

     if( Xrm.Page.data.entity.attributes.get('new_consultant').getValue() !=null)
     {
         var AddressType = Xrm.Page.ui.controls.get('new_consultant');
         AddressType.setDisabled(true);
     }

Thursday, November 3, 2011

Javascript to validate to Phone No in CRM 2011

function checkisinteger()
{
  var s=Xrm.Page.getAttribute('telephone1').getValue();
  if(s!=null)
  {  
    var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
       if (((c < "0") || (c > "9"))) break;
    }
    if(i    {
     alert("Enter a valid phone number");
     Xrm.Page.getAttribute('telephone1').setValue("");
    }
 }
}

Retrieve related entity data (CRM 2011)



Team & users are N:N related. I might need to right 
long LinkEntity query to retrieve users for particular
team. Guess what, I can do it using RelatedEntitiesQuery
property of RetrieveRequest .

QueryExpression query = new QueryExpression(); 
query.EntityName = "systemuser";
 query.ColumnSet = new ColumnSet("systemuserid"); 
Relationship relationship = new Relationship();
 query.Criteria = new FilterExpression();
 query.Criteria.AddCondition(new ConditionExpression("isdisabled",
ConditionOperator.Equal, false)); // name of relationship between team & systemuser relationship.
SchemaName = "teammembership_association"; RelationshipQueryCollection relatedEntity = new RelationshipQueryCollection(); relatedEntity.Add(relationship, query);
RetrieveRequest request = new RetrieveRequest(); request.RelatedEntitiesQuery = relatedEntity; 
request.ColumnSet = new ColumnSet("teamid"); 
request.Target = new EntityReference { Id = teamId, LogicalName = "team" }; RetrieveResponse response = (RetrieveResponse)service.Execute(request);


if (((DataCollection)
(((RelatedEntityCollection)(response.Entity.RelatedEntities)))
).Contains(new Relationship("teammembership_association")) &&
((DataCollection)(((RelatedEntityCollection)
(response.Entity.RelatedEntities))
))[new Relationship("teammembership_association")
].Entities.Count > 0) 
return true; 
else return false;

Renaming the attached file CRM 2011


    I had a requirement in crm 2011 to rename the file what ever we are attaching should be renamed to be a specific name i have achieved this through a plugin  here the code for that plugin

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.IO;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;


namespace FileRenaming
{
    public class filerename : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            // Obtain the execution context from the service provider.
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            // The InputParameters collection contains all the data passed in the message request.
            if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
            {
                // Obtain the target entity from the input parmameters.
                Entity entity = (Entity)context.InputParameters["Target"];
                try
                {
                    IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                    entity["filename"] = "Crm" + "test" + ".doc";                   
                    service.Update(entity);
                }
                catch (InvalidPluginExecutionException)
                {
                    throw new InvalidPluginExecutionException("Error Occured");
                }
            }
        }
    }
}

register this plugin as post synchronous event and it sould be in create message for the primary entity as
annotation


Tuesday, October 25, 2011

Renaming the attached file in CRM

Now i am trying to rename attaching file to a certain "name" and wen i am going through the microsoft forum through my i have got two links which will be help full for achieving this and here is that links

Link 1
Link 2

Thursday, August 18, 2011

A better way to learn LINQ-to-CRM





In Microsoft Dynamics CRM 4.0, we introduced LINQ for our developers through the Advanced Developer Extensions for Microsoft Dynamics CRM 4.0 toolkit. We have further improved this support in Dynamics CRM 2011 by including LINQ as a first class data query mechanism. A better alternative to QueryExpression, LINQ provides a simple, intuitive and unified approach for data retrieval across different data sources.

Those of you who already use LINQ in some other .NET projects are possibly familiar with a great tool that makes LINQ developers’ life easier – LINQPad (www.linqpad.net). LINQPad is similar to SQL Management Studio – it lets you connect to various data sources (for which LINQ providers exist), examine their structure (just like you do with tables and columns in SQL Management Studio), and, finally, write and execute LINQ queries on a fly. LINQPad is a terrific tool to experiment with LINQ. It eliminates a need to create a separate sample C# project to test your queries.

I have written a new tool “LINQPad Plugin for Microsoft Dynamics CRM 2011” to help CRM developers learn and test LINQ queries against any CRM 2011 deployment. The project is available for download from its MSDN Code Gallery page - http://code.msdn.microsoft.com/crmlinqpad

The application is fairly easy to use. You create a connection to a CRM organization by entering organization URL and credentials, and then the plugin retrieves information about the organization’s entities. A tree-like structure of entity sets and entity attributes will be displayed on the left panel of the application. Once that is done, you can write and execute LINQ statements from the main application window. The results of the execution will be shown in a table on the bottom panel.


Features
1) Support of all Microsoft Dynamics CRM 2011 deployment types: Online, OnPremise and SPLA
2) Entity schema browsing – navigating through entity sets, entity attributes and relationships
3) Writing and executing LINQ queries against entity sets
4) Examining QueryExpression used for actual data retrieval

Installation instructions
1) Make sure you have .NET Framework 4.0 and Windows Identity Foundation installed
2) Download and install LINQPad for .NET Framework 4.0 from http://www.linqpad.net
3) Download CrmLINQPadPlugin.lpx from http://archive.msdn.microsoft.com/crmlinqpad/Release/ProjectReleases.aspx?ReleaseId=5329
4) Run LINQPad and register the plugin – go to "Add Connection\View More Drivers\Browse" and select CrmLINQPadPlugin.lpx
5) To create a CRM connection, click "Add Connection" and select "MS CRM 2011" in "Use a typed data context from your own assembly" section



The plugin supports all CRM deployment types – Online, OnPremise and SPLA.
More instructions on how to download and configure LINQPad and the plugin can be found in the Home section of the plugin’s MSDN Code Gallery page.


Friday, August 12, 2011

Some Changes in CRM 2011 plugin coding

There are a lot of syntax and functional changes in MSCRM 2011 plugins. I have listed some of them below:
1. New References
• System.ServiceModel
• System.Runtime.Serialization

2. Microsoft.Crm.Sdk has been replaced by Microsoft.Xrm.Sdk

3. The default parameter for execute method has been changed from
IPluginExecutionContext to IServiceProvide


public void Execute(IServiceProvider serviceProvider)

4. IpluginExecutionContext has been changed to a type of service and to get the reference use the following syntax.

IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));

5. ICrmService has been changed to IOrganizationService

IOrganizationServiceFactory serviceFactory =
IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

6. Dynamic entity has been changed to “Entity”

if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
}


7. Dynamic Entity’s properties syntax has been changed to attributes


entity.Attributes.Contains("accountnumber")

8. Strongly typed classes (account, contact) are missing in Microsoft.XRM.Sdk assembly but there is an exception to this.

9. CRM 2011 provides the crm utility called “crmsvcutil” to generate strongly typed classes that can be used in plugins.

10. Strongly typed classes has been changed to use like loosely typed classes.
Task task = new Task();
Task[“description”] = ”test description”

11. No more soap exception
catch (FaultException ex)

Plugin Development in 2011

1. Create a class library project in vs2010.
2. Sign the assembly by using the Signing tab of the project's properties sheet.
3. Add references to microsoft.crm.sdk.proxy , Microsoft.xrm.sdk ,
System.ServiceModel and System.Runtime.Serialization.
4. Here is code for this tutorial. This plugin will check if the account number
field is empty, create a task for the user to fill this up.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Microsoft Dynamics CRM namespace(s)
using Microsoft.Xrm.Sdk;
using System.ServiceModel;

namespace CRMPlugin1
{
public class createNote:IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{

// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));


// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parmameters.
Entity entity = (Entity)context.InputParameters["Target"];



try
{
//check if the account number exist

if (entity.Attributes.Contains("account number") == false)
{

//create a task
Entity task = new Entity("task");
task["subject"] = "Account number is missing";
task["regardingobjectid"] = new EntityReference("account",new Guid(context.OutputParameters["id"].ToString()));

//adding attribute using the add function
// task["description"] = "Account number is missng for the following account. Please enter the account number";
task.Attributes.Add("description", "Account number is missng for the following account. Please enter the account number");



// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);


// Create the task in Microsoft Dynamics CRM.
service.Create(task);


}
}

catch (FaultException ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}

}

}
}//end class
}//end name space


5. Compile the code and register it on the registration tool provided with sdk.
6. Register it on the post create event of account entity.
Note :check the sdk for instructions to register a plugin

Tuesday, August 2, 2011

Sql server Integration Service


using the ssis(sql server integration service) we can easily intergrate the sql table with a excel sheet
sql table is source and excel sheet is destination

by running the new ssis import export wizard we can easily create the ssis integration project
in this it will automatically create the excel file in your specified path and it will be integrating with that file

problem in this is if we are again running the integration project means it will show erroror it
will create duplicate data in the destination excel for that we can add a script task before all the things and

we can write the code to delete the existing excel file so that our ssis project  wil be working smoothly


in C# we have a class for manipulating all the file operations ..


  System.IO.File

you can write the code like this in the script task



if(System.IO.File.Exist("path\filename.xls"))
{
   System.IO.File.Delete("path\filename.xls");
}

Thursday, July 28, 2011

Microsoft says that SQL Server Integration Services (SSIS) “is a platform for building high performance data integration solutions, including extraction, transformation, and load (ETL) packages for data warehousing.” A simpler way to think of SSIS is that it’s the solution for automating SQL Server. SSIS provides a way to build packages made up of tasks that can move data around from place to place and alter it on the way. There are visual designers (hosted within Business Intelligence Development Studio) to help you build these packages as well as an API for programming SSIS objects from other applications.








I have done the integration successfully ….if u want to try follow this link





Monday, July 25, 2011

File and Directory Commands in Ubuntu System

cd

The cd command changes directories. When you open a terminal you will be in your home directory. To move around the file system you will use cd.
  • To navigate into the root directory, type:
    cd /

  • To navigate to your home directory, type:
    cd
    or
    cd ~


    The ~ character represents the current user's home directory. As seen above, cd ~ is equivalent to cd /home/username/. However, when running a command as root (using sudo, for example), ~ points instead to /root. When running a command with sudo, the full path to your home directory must be given.
  • To navigate up one directory level, type:
    cd ..

  • To navigate to the previous directory (or back), type:
    cd -

  • To navigate through multiple levels of directories at once, specify the full directory path that you want to go to. For example, type:
    cd /var/www
    to go directly to the /www subdirectory of /var/. As another example, type:
    cd ~/Desktop
    to move you to the Desktop subdirectory inside your home directory.

pwd

The pwd command outputs which directory you are currently located in (pwd stands for “print working directory”). For example, typing
pwd
in the Desktop directory, will show /home/username/Desktop.




ls

The ls command outputs a list of the files in the current directory. For example, typing
ls ~
will show you the files that are in your home directory.
Used with the -l options, ls outputs various other information alongside the filename, such as the current permissions on the file, and the file's owner.

cp

The cp command makes a copy of a file. For example, type:
cp foo bar
to make an exact copy of foo and name it bar. foo will be unchanged.

mv

The mv command moves a file to a different location or will rename a file. Examples are as follows:
mv foo bar
will rename the file foo to bar.
mv foo ~/Desktop
will move the file foo to your Desktop directory but will not rename it.

rm

rm is used to delete files.
rm foo
deletes the file foo from the current directory.
By default, rm will not remove directories. To remove a directory, you must use the -R option. For example,
rm -R foobar
will remove the directory foobar, and all of its contents!

mkdir

The mkdir command allows you to create directories. For example, typing:
mkdir music
will create a directory named music in the current directory.

How to Enable and Disable Usb Drive in a Windows system

Dear Friends  
     
   Got to know about enabling and disabling usb in a windows System .You can also do this by following some easy steps ...please follow these steps

 Press Windows + r  
    you will get the run Window in that type regedit, and then click OK.


u will get to see registry editor window in that navigate to the following path
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor


in that u will see the Default file click on that and
In the Value data box, type 3  click OK
it will enable the USB access in your windows System

if you want to disable enter 4 click ok..  and it will disable your USB access on Windows System...




Saturday, July 23, 2011

CRM Main Modules

CRM Systems as main player in CRM(Customer Relationship Management) Industry provides basic modules generally used in the CRM industry. Such modules involves general business process in CRM. Those modules are:

Sales Module
 CRM Sales Module provides up-to-the-moment, proactive intelligence to maximize sales revenue. With  CRM Sales all levels of the selling organization can access the facts required to confidently pinpoint problems and deploy resources. CRM Sales allows managers to monitor sales pipelines and evaluate the performance of the entire sales distribution network.  CRM Sales enables sales professionals to identify critical trends in sales cycle length, win rates, discounting, and competitive engagement. This level of visibility is vital to any organization deploying a high-performing sales force.

Marketing  Module
CRM Marketing  Module provides the campaign management, customer management and marketing communications functionality. Users can design and manage outbound campaigns through direct sales, call centers, and channel partners. CRM Marketing also provides list management capabilities to develop internal lists and load external list files and prospect management with promotion of prospects to contacts.  Marketing's response management enables marketers to track customer responses and evaluate campaign effectiveness.

Service Module
CRM Service module enable customer agents interact quickly and consistently across a broad range of communication channels, such as telephone, email, fax, and page. Service representatives become productive faster, supporting a broader range of products and services, resulting in higher satisfaction levels in each customer interaction.  

Friday, July 22, 2011

Extended CRM


Add the Reference to our project in Visual Studio from SDK kit

Microsoft.Crm.SdkTypeProxy;
Microsoft.Crm.Sdk;

Add the follwing code means Namespaces

using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Crm.Sdk;


Creating a crmservice using the c# code

class CrmServiceClass
    {
        public CrmService createcrmservice()
        {
            // Set up the CRM Service.
            CrmAuthenticationToken token = new CrmAuthenticationToken();
            token.AuthenticationType = 0;
            token.OrganizationName = "Organization Name";

            CrmService service = new CrmService();
            service.Url = "http://localhost:5555/mscrmservices/2007/crmservice.asmx";
            service.CrmAuthenticationTokenValue = token;
            service.Credentials = new System.Net.NetworkCredential("user", "password", "Domain Name");
             //The Commented line is used to get the default login details means it will take the user currently logined
            // service.Credentials = System.Net.CredentialCache.DefaultCredentials;
            return service;

        }
    }


Method used to Create a Entity in CRM 


 class createEntity
    {
        public void createentity()
        {
            CrmServiceClass obj=new CrmServiceClass();
            CrmService  service = (CrmService)obj.createcrmservice();
            // Create an account entity and assign data to some attributes.
            account newAccount = new account();
            newAccount.name = "Athul";
            newAccount.accountnumber = "123456";
            newAccount.address1_postalcode = "98052";
            newAccount.address1_city = "Redmond";

            contact newcontact = new contact();
            newcontact.firstname = "athul";
            newcontact.fullname = "Athul Mt";
            newcontact.emailaddress1 = "athulmt@gmail.com";
            // Call the Create method to create an account.
            Guid accountId = service.Create(newAccount);
            Guid conatctId = service.Create(newcontact);
        }
    }


Method to update a Entity


class updateEntity
    {
        public void updateentity()
        {
            CrmServiceClass obj = new CrmServiceClass();
            CrmService service = (CrmService)obj.createcrmservice();
            DynamicEntity dynAccount = new DynamicEntity("account");
            dynAccount.Properties.Add(CrmTypes.CreateKeyProperty("accountid", new Key(new Guid("10AA7D61-25B4-E011-B20B-000C29B9B349")))); //give the record guid within quotes
            dynAccount.Properties.Add(CrmTypes.CreateStringProperty("name", "Test Account 2"));

            TargetUpdateDynamic target = new TargetUpdateDynamic();
            target.Entity = dynAccount;

            UpdateRequest request = new UpdateRequest();
            request.Target = target;
            UpdateResponse response = (UpdateResponse)service.Execute(request);
            Console.WriteLine("record updated");
            Console.Read();
        }
    }

Monday, July 18, 2011

How to change Sql server Windows Authentication to Mixed Mode Authentication

I have installed Sql Server 2008 express edition but by mistake I kept the windows authentication mode.

Now I want to change that to SQL SERVER MIXED mode. How to do this?

Ans:-

Right click on server which you have connected
In that select Server Properties - Security - [Server Authentication section] you check Sql Server and Windows authentication mode

C#

What is an Abstract Class?

An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

What is an Interface?

An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn�t support multiple inheritance, interfaces are used to implement multiple inheritance.

Both Together

When we create an interface, we are basically creating a set of methods without any implementation that must be overridden by the implemented classes. The advantage is that it provides a way for a class to be a part of two classes: one from inheritance hierarchy and one from the interface.

When we create an abstract class, we are creating a base class that might have one or more completed methods but at least one or more methods are left uncompleted and declared abstract. If all the methods of an abstract class are uncompleted then it is same as an interface. The purpose of an abstract class is to provide a base class definition for how a set of derived classes will work and then allow the programmers to fill the implementation in the derived classes.

Type Casting

Converting an expression of a given type into another type is known as type-casting.

Implicit conversion

Implicit conversions do not require any operator. They are automatically performed when a value is copied to a compatible type

short a=2000;

int b;

b=a;



Explicit conversion

C++ is a strong-typed language. Many conversions, specially those that imply a different interpretation of the value, require an explicit conversion.



short a=2000;

int b;

b = (int) a; // c-like cast notation

b = int (a); // functional notation

sealed class

A sealed class cannot be inherited. It is an error to use a sealed class as a base class. Use the sealed modifier in a class declaration to prevent inheritance of the class.

sealed class MyClass

{

public int x;

public int y;

}

Wednesday, June 8, 2011

Microsoft Dynamics AX

Microsoft Dynamics AX is one of Microsoft’s enterprise resource planning software products.

History

Microsoft Dynamics AX was originally developed as a collaboration between IBM and Damgaard as IBM Axapta. IBM returned all rights in the product to Damgaard shortly after the release of Version 1.5. before Damgaard was merged with Navision Software A/S in 2000. The combined company, initially NavisionDamgaard, later Navision A/S, was then ultimately acquired by the Microsoft Corporation in the summer of 2002.[3] Before the merger, Axapta was initially released in March, 1998 in the Danish and U.S. markets. Today, it is available and supported in forty-five languages in most of the world.

Custom AX development and modification is done with its own IDE, MorphX, and resides in the same client application that a normal day-to-day user would access, thus allowing development to take place on any instance of the client. The development language used in Axapta is X++.

On May 26, 2008, Microsoft completed developing the latest version (2009) in facilities spanning the globe and including sites in Vedbæk, Denmark; Kiev, Ukraine; Fargo, North Dakota, United States; and Redmond, Washington, United States.

Architecture

The Microsoft Dynamics AX software is composed of four major components:

The Database Server, a database that stores the Microsoft Dynamics AX data
The File Server, a folder containing the Microsoft Dynamics AX application files
The Application Object Server(s) (AOS), a service that controls all aspects of Microsoft Dynamics AX's operation
The Client(s), the actual user interface into Microsoft Dynamics AX

 
MorphX and X++

MorphX is an integrated development environment in Microsoft Dynamics AX that allows developers to graphically design data types, base enumerations, tables, queries, forms, menus and reports. MorphX supports drag-and-drop and is very intuitive. It also allows access to any application classes that are available in the application, by launching the X++ code editor.

Because MorphX uses referencing to link objects together, changes in, for example, datatypes of fieldnames will automatically be reflected in all places where they are used (such as forms or reports). Furthermore, changes made through MorphX will be reflected in the application immediately after compilation.

Microsoft Dynamics AX also offers support for version control systems (VCS) integrated with the IDE, allowing collaboration in development. There is also a tool for reverse-engineering table structures and class structures to Visio. The actual implementation limits the practical use of both these features.

X++ itself is the programming language behind MorphX, and belongs to the curly brackets and .-operator class of programming languages (like C# or Java). It is an object-oriented class-based single dispatch language. X++ is a derivative of C++ (both lack the finally keyword for example) to which garbage collection and language integrated SQL queries were added.

Friday, May 27, 2011

MicroSoft Dynamics

In the field of application software, Microsoft Dynamics is a line of ERP (enterprise resource planning) and CRM (customer relationship management) applications developed by the Microsoft Business Solutions group

History

The Microsoft Business Solutions group formed in part from Microsoft’s acquisition of two software companies: Great Plains Software, acquired in April 2001, and Navision, acquired in July 2002.
Microsoft Dynamics CRM entered the CRM market in 2003. The Microsoft Business Solutions group now includes the Microsoft Dynamics ERP product group and Microsoft Dynamics CRM product group.
Microsoft Dynamics industry solutions include Microsoft Dynamics POS (Point of Sale), introduced in 2009, and Microsoft Dynamics Retail Management System (RMS).

Products

Microsoft Dynamics is a line of enterprise resource planning (ERP) and customer relationship management (CRM) applications.
Microsoft Dynamics ERP is an enterprise resource planning application primarily geared toward midsize organizations as well as subsidiaries and divisions of larger organizations. Microsoft Dynamics ERP includes five primary products:
  • Microsoft Dynamics AX (formerly Axapta)
  • Microsoft Dynamics GP (formerly Great Plains Software)
  • Microsoft Dynamics NAV (formerly Navision)
  • Microsoft Dynamics SL (formerly Solomon IV)
  • Microsoft Dynamics C5 (formerly Concorde C5)
Microsoft Dynamic CRM

Microsoft Dynamics CRM is a customer relationship management software package developed by Microsoft. Out of the box, the product focuses mainly on Sales, Marketing, and Service (help desk) sectors, but Microsoft has been marketing Dynamics CRM as an XRM platform and has been encouraging partners to use its proprietary (.NET based) framework to customize it to meet many different demands. 

Monday, March 21, 2011

Sql Server

Few days Befor I have tried a lot to get the date in different format SQL

SELECT GETDATE()
ResuleSet:
2007-06-10 7:00:56.107
The required outcome was only 2007/06/10.

SELECT DATEADD(D, 0, DATEDIFF(D, 0, GETDATE()))

using function CONVERT.

SELECT CONVERT(VARCHAR(10),GETDATE(),111)

The reason I use this because it is very convenient as well as provides quick support to convert the date in any format. The table which suggest many format are displayed on MSDN.
Some claims that using CONVERT is slower then using DATE functions but it is extremely negligible.