Friday, August 27, 2010

Setting the Default View in CRM

Although the default view of entities in CRM is generally adequate, many times you will want to change the default view to something else. You do this by going to Settings-> Customization-> Customize Entities and then editing the entity in question.

I will customize the Contact entity. Select Forms and Views and then select My Active Contacts (only select we don't want to edit at this time). Now click the More Actions button and Set Default. Now you've changed your default view.

Tuesday, August 24, 2010

Turn off the CRM Tracking Number in Email Subject Lines

Turning off the tracking number in the email subject line is a simple proposition in CRM. Simply go to Settings-->Administration-->System Settings. Select the E-mail tab and uncheck the "Use tracking token" check box.

Monday, August 23, 2010

Custom Entity in Microsoft Dynamics CRM

In this post I will walk you through creating a custom entity in Microsoft Dynamics CRM 4.0.

CRM makes it easy to create a simple entry form that can be used to store data. First, navigate to the customization section by going to Settings-Customization and selecting Customize Entities. Then click the New button.

Some basic information must be completed for the new entity, such as Name, ownership and where you want this new entity to appear. We will create an entity named Album to store information about... well, albums. We will select User for the Ownership and uncheck Activities from the relationships. Also, I will show this new entity in Service, so we will check that box. On the Primary Attribute tab, I am just taking all of the defaults. Click Save and you have yourself a new custom entity. At this point it will only hold the name of the album and some notes, so let's create some attributes for our album.



To create attributes go to the Attributes tab and select New. Type Artist in the Display Name field and click the Save and New button. Do the same for Title. The nvarchar datatype is fine for those two attributes, but now let's add Release Date as an attribute and specify datetime for the Type. Again, click Save and New and let's create a rating attribute and specify a type of Picklist. You now have the ability to add pick list options. I added the options in the image below, but you can make the values whatever you like. Click Save and Close.

Now that we have some custom attributes, let's add them to our form. Select Forms and Views from the Album tab and then double-click the Form entry. Next, select Add Fields and select the four attributes you just created. Arrange the entities on the form however you like. I included a screenshot of what my form looks like. You can also preview what the form will look like by selecting Preview from the toolbar and then Create Form. When you are satisfied with your product select Save and Close. Now click the Publish button from the Album form to publish your changes.






Next, browse to the Service Section and add albums.

Wednesday, August 18, 2010

Using the bcp Utility to Export Data to a CSV File with Microsoft SQL Server 2008

In previous blog posts I have demonstrated how data can be imported into a SQL server database table from a CSV file.  In this post I will introduce the bcp (Bulk Copy Program) utility that can be used to export the results of a query to a CSV file.  The bcp utility is included in the SQL Server installation and can be invoked from the command line or included in a batch file.  If you needed to create a CSV file in a specified directory once per day you could create a batch file that includes a call to bcp and schedule the batch file to run daily.

Below is an example of bcp command export a list of employee names and phone numbers to a CSV file.   The command could be executed from the command line or as part of a batch file
.

bcp "SELECT LastName, FirstName, HomePhone FROM Northwind.dbo.Employees ORDER BY LastName, FirstName" queryout "employees.csv" -T -S . -w -t,

The first part "bcp" is the name of the executable program.  When using it at the command line or in a batch file make sure that its parent directory is included in your path variable.  Next in quotes is the SELECT statement that will generate the results. I am using the sample Northwind database.  I have included the database name "Northwind" and schema "dbo" in my FROM clause.  The queryout parameter instructs the bcp utility to export the query results to a file specified by the next parameter "employees.csv".  The –T specifies that integrated authentication will be used.  If we wanted to use SQL authentication this is also supported.  The  –S parameter specifies the server, in this case the local machine. The –w parameter instructs bcp to treat the data as Unicode characters.  The –t parameter specifies that a comma be used as the field delimited instead of the default tab character.  Note that command arguments are case-sensitive "-t" is not the same as "-T".


Here is a screen shot of the employees.csv text file.


You can see from the screenshot that the files created using the bcp utility do not include column headings. 

This post is a basic introduction to the bcp utility. The bcp utility has other capabilities: it can be used to import data, similar to the BULK IMPORT statement, and it can also be used to create format files.

References

Bcp Utility from SQL Server Books Online:

Wednesday, August 11, 2010

How to add a new or modify existing Report Wizard styles templates to SQL Server 2005 Reporting Services:


This is accomplished by editing StyleTemplates.xml which is located at

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\Business Intelligence Wizards\Reports\Styles\en

Make a backup of StyleTemplates.xml before starting. The StyleTemplate.xml is in the following format.

<styletemplates>
<styletemplate name="Template Name">
<label>Name that will be shown in wizard</label>
<styles>
<style name="Name of element to be styled">
[Elements from RDL Style.]
</style>
</styles>
</styletemplate>
</styletemplates>


To add a new template simply copy an old template by selecting all the tags between the </StyleTemplate Name></StyleTemplate> tags and paste after a </StyleTemplate> tag.



<StyleTemplate Name="Slate">
<Label>Slate</Label>
<Styles>
<Style Name="Title">
<FontFamily>Tahoma</FontFamily>
<FontSize>20pt</FontSize>
<Color>SteelBlue</Color>
<FontWeight>Bold</FontWeight>
</Style>
<Style Name="Page Group Level 1">
<FontFamily>Tahoma</FontFamily>
<FontSize>14pt</FontSize>
<Color>SlateGray</Color>
</Style>
<Style Name="Page Group Level 2">
<FontFamily>Tahoma</FontFamily>
<FontSize>12pt</FontSize>
</Style>
<Style Name="Page Group Level 3+">
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
</Style>
<Style Name="Table"></Style>
<Style Name="Matrix"></Style>
<Style Name="Table Header">
<BackgroundColor>SteelBlue</BackgroundColor>
<FontFamily>Tahoma</FontFamily>
<FontSize>11pt</FontSize>
<FontWeight>Bold</FontWeight>
<Color>White</Color>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
</Style>
<Style Name="Group Level 1">
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<Color>White</Color>
<BackgroundColor>#6e9eca</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
</Style>
<Style Name="Group Level 1 Textbox">
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<Color>White</Color>
<BackgroundColor>#6e9eca</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
</Style>
<Style Name="Group Level 2">
<Color>White</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<BackgroundColor>SlateGray</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
</Style>
<Style Name="Group Level 2 Textbox">
<Color>White</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<BackgroundColor>SlateGray</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
</Style>
<Style Name="Group Level 3+">
<Color>White</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<BackgroundColor>#8fa0b0</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
</Style>
<Style Name="Group Level 3+ Textbox">
<Color>White</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<BackgroundColor>#8fa0b0</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
</Style>
<Style Name="Detail">
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>LightGrey</Default>
</BorderColor>
</Style>
</Styles>
</StyleTemplate>


Produces a report that looks like this.



By modifying the xml file. You can change the colors, fonts and other elements to reflect your company’s color themes and styles.


I’ve added a style called SAMPLE to the StyleTemplates.xml



<StyleTemplate Name="SAMPLE">
<Label>SAMPLE</Label>
<Styles>
<Style Name="Title">
<FontFamily>Arial</FontFamily>
<FontSize>12pt</FontSize>
<Color>#000000</Color>
<FontWeight>Bold</FontWeight>
</Style>
<Style Name="Page Group Level 1">
<FontFamily>Arial</FontFamily>
<FontSize>10pt</FontSize>
<Color>#ebebeb</Color>
</Style>
<Style Name="Page Group Level 2">
<FontFamily>Arial</FontFamily>
<FontSize>10pt</FontSize>
</Style>
<Style Name="Page Group Level 3+">
<FontFamily>Arial</FontFamily>
<FontSize>8pt</FontSize>
</Style>
<Style Name="Table"></Style>
<Style Name="Matrix"></Style>
<Style Name="Table Header">
<BackgroundColor>#ebebeb</BackgroundColor>
<FontFamily>Arial</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<Color>#000000</Color>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>#000000</Default>
</BorderColor>
</Style>
<Style Name="Group Level 1">
<FontFamily>Arial</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<Color>#000000</Color>
<BackgroundColor>#ebebeb</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>#000000</Default>
</BorderColor>
</Style>
<Style Name="Group Level 1 Textbox">
<FontFamily>Arial</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<Color>#000000</Color>
<BackgroundColor>#ebebeb</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>#000000</Default>
</BorderColor>
</Style>
<Style Name="Group Level 2">
<Color>White</Color>
<FontFamily>Arial</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<BackgroundColor>SlateGray</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>#000000</Default>
</BorderColor>
</Style>
<Style Name="Group Level 2 Textbox">
<Color>White</Color>
<FontFamily>Arial</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<BackgroundColor>SlateGray</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>#000000</Default>
</BorderColor>
</Style>
<Style Name="Group Level 3+">
<Color>White</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<BackgroundColor>#8fa0b0</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>#000000</Default>
</BorderColor>
</Style>
<Style Name="Group Level 3+ Textbox">
<Color>White</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<FontWeight>Bold</FontWeight>
<BackgroundColor>#8fa0b0</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>#000000</Default>
</BorderColor>
</Style>
<Style Name="Detail">
<FontFamily>Tahoma</FontFamily>
<FontSize>10pt</FontSize>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<BorderColor>
<Default>#000000</Default>
</BorderColor>
</Style>
</Styles>
</StyleTemplate>


Once I have saved the file, I am ready to create a new report. Simply select the new report style from the report wizard.



An example of the SAMPLE style report is below:


Wednesday, August 4, 2010

Set a Default Date in Dynamics CRM 4.0 Using JavaScript

This blog will demonstrate how to set a default due date for the Phone Call entity in Dynamics CRM 4.0 by using a little bit of JavaScript.

T0 start go to Settings-->Customization-->Customize Entities. Scroll down to Phone Call and edit it by double-clicking or selecting More Actions and Edit from the toolbar.


Next, select Forms and Views and edit the Form. Select Form Properties and click the Edit button for the OnLoad Event. Copy the following code into the editor and click OK.

var CRM_FORM_TYPE_CREATE = "1";
var DUE;
var TODAY;

// Only make these changes when the form is opened in Create mode.
if (crmForm.FormType==CRM_FORM_TYPE_CREATE)
{
// Get today's date.
TODAY = new Date();

DUE = TODAY.setDate( TODAY.getDate());
crmForm.all.scheduledend.DataValue = DUE;
}




Now let's test our work by selecting Preview and Create Form. You will notice that the default value for Completed Date is now the current date and time. Note that I changed the "Due" to "Completed" date on the form editor.





Monday, August 2, 2010

Microsoft Dynamics CRM - Rename Attributes and Rearrange Them

In this entry I will demonstrate how to customize Microsoft Dynamics CRM 4.0 by renaming attributes and rearranging them on a form.

To start go to Settings-->Customization-->Customize Entities and select the entity you want to customize by double-clicking or selecting More Actions and Edit. For our example, I will customize Lead.



To change the display name of an item on the form select Attributes and select attribute to rename and Edit. For our example I will change "E-mail Address 1" to "E-mail".


Save and Close the open forms then select "Forms and Views" and edit the Form object. Next, to move the E-mail address to Contact Information, use the arrow buttons on the right hand side of the Lead Form editor to rearrange attributes as you like.


When you have everything arranged like you want, publish the customizations by clicking the Publish button.

I hope you enjoyed this quick walk-through about how to rename and rearrange attributes in Microsoft Dynamics CRM 4.0