-
Finding the value of the state and status codes
If you’ve ever wondered how to find the values for the statecode and statuscode, you can use the following SQL script to find those values:
selectAttributeName,
AttributeValue,
Valuefrom dbo.StringMapwhere(dbo.StringMap.AttributeName = 'statuscode'ordbo.StringMap.AttributeName = 'statecode')anddbo.StringMap.ObjectTypeCode = 1
Will display the following values for the Account Entity ( ObjectTypeCode = 1 ):
AttributeName AttributeValue Value statecode
0
Active
statecode
1 Inactive
statuscode
1 Active
statuscode
2 Inactive
Customization, Dynamics CRM 481 views -
Testing Customizations as a Normal User
This will probably be old news to most of you, but for those who are just starting with CRM, you should have a methodology in place to test your customizations as a normal user.
The Basics
You should have at least one test user for each role in which normal users exist. Normal being not-CRM Administrators. This will allow you to test the functionality of your customizations and custom solutions as each type of user.
While this may not seem like a huge issue, you need to keep in mind that CRM alters the environment and the user interface based on the user’s security. This means that sometimes they will not see things you expect them to or they will have permissions issues where you least expect them.
How to Test
Prior to Windows Vista and Server 2008, you could simply right-click on the Internet Explorer icon, select Run As, then supply the credentials of whatever test user you wished.
Unfortunately, Microsoft changed that behavior and according to this article, it no longer works. Thanks guys.
A possible work-around is using the ShellRunAs commandlet found here.
It is supposed to provide this functionality but I’ve had mixed results ( probably didn’t follow the directions properly ).
So if you’re using Vista or Server 2008, should nothing else work, you can always just Switch Users and log into the machine as the test user.
What to Test
Here are the usual suspects for testing customizations within CRM:
- The Site Map ( left-hand navigation )
- ISV.Config ( buttons and menus )
- JavaScript ( does your custom JavaScript work with all users )
- Custom Solutions ( any custom ASP.NET code you have written and added to CRM )
- Processes. If you have a process that moves data through the system, test it from start to finish as the particular user or users who actually perform the work to make sure you’re covering the whole process as a “normal” user and experiencing what they experience.
Conclusion
This is, at the very least, the minimal amount of testing you need to perform on a customized system. You can get as comprehensive and complex as you desire.
If you will document your testing procedures and steps and repeat those each time a change is made, you should be able to more quickly identify problems and create solutions before your changes reach the hands of the users.
Administration, Customization, Dynamics CRM, Installation 473 views -
CRM Customization File Best Practices
Today I thought I’d share what I think are some best practices when working with CRM’'s customization files.
Procedure
When exporting customizations for either edit (ISV.Config or Site Map ) or transport, I always save them to disk so I have a reference copy of the customizations.
Location
Pick a specific folder on your system an always store your exported customization files there. It helps to always have your customizations in a central place should you need to revert or refer back to a previous version.
File Naming Convention
Over time, I’ve developed the following convention to help me organize my export files:
[organization]-[dev/prod]-[entity]-customizations-[date].zip
Examples:
contoso-dev-sitemap-isvconfig-customizations-0820.zip
contoso-prod-all-customizations-20090820.zip
If I am exporting all customizations, I just use that for the entity name. Since I rarely export customizations for specific entities besides the SiteMap and ISV.Config, I don’t usually have to worry about having too long of a file name.
If you are working on a development team, you may also add your name ( or email alias ) to the file name so everyone knows who saved the customizations.
Unpacking
If I need to edit the exported customizations, I will first unzip them into a folder with the same name as the .zip file so that I can edit a copy of the customization file. This also gives me a reference copy of the file should I need it later.
Editing
If at all possible, use Visual Studio to edit the customization.xml file. This will prevent possible illegal formatting that will prevent CRM from reloading your customizations.
Now this is probably a duplication of effort, but the first thing that I do after opening the file in Visual Studio is perform a Save As operation, giving the new file the following name:
customizations-NEW.xml
After editing, this is the file that will, of course, be re-imported into CRM.
Conclusion
Well, that’s about it for today. While most of what I’ve shared is pretty much common sense, I thought I’d write about it so that people just starting have a starting point when working with customizations.
If you have your own best practices, I’d love to hear them.
Customization, Dynamics CRM 516 views -
Changing CRM’s Customization Navigation
If you’re like me and spend much of your day importing, exporting, and publishing customizations, you’re probably a bit tired of some of the excess clicking required to accomplish those processes.
I dedicated a bit of time yesterday researching how I could move the main Customize, Export, and Import functions from the Customization page to the left-hand navigation so that these functions could be accessed with a single click. Here’s what I came up with:
This is all done using modifications to the CRM Site Map.
Step 1
The first step in this process is modifying the Settings area and adding the ShowGroups option, as shown below:
<Area Id="Settings"
ResourceId="Area_Settings"
Icon="/_imgs/settings_24x24.gif"
DescriptionResourceId="Settings_Area_Description"
ShowGroups="true">
Step 2:
We need to add a new Group containing the new navigation items. It should look something like this:
<Group Id="m3_customizations"> <Titles> <Title LCID="1033" Title="Customizations"/> </Titles> <Descriptions> <Description LCID="1033" Description="CRM Customization Functions"/> </Descriptions> <SubArea Id="m3_customize" Icon="/_imgs/SystemCustomization/ico_entityManagement.gif" Url="http://crm/contoso/tools/systemcustomization/systemcustomization.aspx?pid=01" AvailableOffline="false"> <Titles> <Title LCID="1033" Title="Customize Entitites"/> </Titles> <Descriptions> <Description LCID="1033" Description="Customize Entities"/> </Descriptions> </SubArea> <SubArea Id="m3_exportcustomizations" Icon="/_imgs/SystemCustomization/ico_exportCustomizations.gif" Url="http://crm/contoso/tools/systemcustomization/systemcustomization.aspx?pid=02" AvailableOffline="false"> <Titles> <Title LCID="1033" Title="Export Customizations"/> </Titles> <Descriptions> <Description LCID="1033" Description="Export Customizations"/> </Descriptions> </SubArea> <SubArea Id="m3_importcustomizations" Icon="/_imgs/SystemCustomization/ico_importCustomizations.gif" Url="http://crm/contoso/tools/systemcustomization/systemcustomization.aspx?pid=03" AvailableOffline="false"> <Titles> <Title LCID="1033" Title="Import Customizations"/> </Titles> <Descriptions> <Description LCID="1033" Description="Import Customizations"/> </Descriptions> </SubArea> </Group>
The new Customizations Group contains three subareas: Customize, Export and Import. Each points to the URL that handles that specific function within CRM. This is the same URL that CRM uses, we’ve just moved it into the navigation structure.
Caveats
The only real issue that I have with this solution is you must specify the full URL to these sites. I tried a relative path but it would not display properly. This is an issue if you are moving customizations between servers and/or organizations but it’s not a huge issue to overcome.
You’ll also notice that I only moved three of the six items on the Customization page. The other three items are used so infrequently that they don’t warrant occupying space within the navigation structure.
Customization, Dynamics CRM 699 views -
JavaScript: Get a value from a parent form
It is not an uncommon requirement to pull data for from the parent entity of the current record. In many cases, this child entity is only created from its parent so we can simply just reference the window.opener object to get a reference to the parent form.
An example would be creating a new Contact or Order from inside the Account form.
I got tired of writing this code over and over so yesterday I set down to attempt a solution that would be dynamic and I could just call from the Form’s OnLoad event. Here’s my solution:
function GetParentFormFieldValue(fieldName){var retVar = null;
if ((window.opener != null) &&(window.opener.parent != null) &&(window.opener.parent.document != null) &&(window.opener.parent.document.crmForm != null))
{eval("retVar = window.opener.parent.document.crmForm.all." + fieldName + ".DataValue");
}
return retVar;}
It is used like this:
crmForm.all.name.DataValue = "New order for " + GetParentFormFieldValue("name");
Customization, Dynamics CRM 965 views -
Free Utility: CRM Export
Based on the conversations I had with people after releasing the JavaScript Export utility, I decided to go ahead and release a second utility I created that will export all customizations from a specified CRM entity.
CRM Export is a command-line tool that allows you to specify connection and configuration information as parameters. This will allow you to execute the utility in an automated manner using Windows Scheduler.
You will find CRM Export in the Free Utilities section.
Customization, Dynamics CRM 466 views -
CRM 4.0’s Built-in SQL Functions (Part 5 of 5)
The final installment in this series contains miscellaneous SQL functions.
You may wish to review the following articles before proceeding:
CRM 4.0’s Built-in SQL Functions (Part 1 of 5)
CRM 4.0’s Built-in SQL Functions (Part 2 of 5)
CRM 4.0’s Built-in SQL Functions (Part 3 of 5)
CRM 4.0’s Built-in SQL Functions (Part 4 of 5)
dbo.fn_FindBusinessGuid
This function will return the ID for the business unit for the currently logged-on user.
select dbo.fn_FindBusinessGuid()dbo.fn_FindUserGuid
This function will return the CRM ID for the currently logged-on user.
select dbo.fn_FindUserGuid()Conclusion
I hope you enjoyed this series which explored the built-in user-defined functions included with CRM 4.0. Hopefully, it will make your report writing quicker and more powerful.
I have a couple of additional articles planned that will cover some of these functions in more detail in the future.
Customization, Dynamics CRM, Reporting 348 views -
CRM 4.0’s Built-in SQL Functions (Part 4 of 5)
In this section, we’ll cover year-related functions.
You may wish to review the following articles before proceeding:
CRM 4.0’s Built-in SQL Functions (Part 1 of 5)
CRM 4.0’s Built-in SQL Functions (Part 2 of 5)
CRM 4.0’s Built-in SQL Functions (Part 3 of 5)
dbo.fn_BeginOfLastYear
Returns the beginning date and time for last year.
This function requires a valid datetime value.
select dbo.fn_BeginOfLastYear(GetUTCDate())Returns: 2008-01-01 06:00:00.000
dbo.fn_BeginOfNextYear
Returns the beginning date and time for next year.
This function requires a valid datetime value.
select dbo.fn_BeginOfNextYear(GetUTCDate())Returns: 2010-01-01 06:00:00.000
dbo.fn_BeginOfThisYear
Returns the beginning date and time for this year.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_BeginOfThisYear(GetUTCDate())Returns: 2009-01-01 06:00:00.000
dbo.fn_BeginOfYear
Returns the beginning date and time of a year.
This function requires a valid datetime value.
select dbo.fn_BeginOfYear(GetUTCDate())Returns: 2009-01-01 06:00:00.000
dbo.fn_EndOfLastYear
Returns the ending date and time for last year.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfLastYear(GetUTCDate())Returns: 2009-01-01 06:00:00.000
dbo.fn_EndOfNextYear
Returns the ending date and time for next year.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfNextYear(GetUTCDate())Returns: 2011-01-01 06:00:00.000
dbo.fn_EndOfThisYear
Returns the ending date and time for this year.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfThisYear(GetUTCDate())Returns: 2010-01-01 06:00:00.000
dbo.fn_LastXYear
Returns the date from X number of years ago ( from today ).
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_LastXYear(GetUTCDate(), 1)Returns: 2008-08-16 05:00:00.000
dbo.fn_NextXYear
Returns a date that is X number of years in the future ( from today )
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_NextXYear(GetUTCDate(), 1)Returns: 2010-08-17 05:00:00.000
Customization, Dynamics CRM, Reporting 375 views -
CRM 4.0’s Built-in SQL Functions (Part 3 of 5)
Today we are continuing on with part three of our series on using CRM 4.0’s built-in SQL functions.
You may wish to review the following articles:
CRM 4.0’s Built-in SQL Functions (Part 1 of 5)
CRM 4.0’s Built-in SQL Functions (Part 2 of 5)
Note: The date used in the following example is 2009-08-16.
dbo.fn_BeginOfLastMonth
Return the beginning date and time of last month.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_BeginOfLastMonth(GetUTCDate())Returns: 2009-07-01 05:00:00.000
dbo.fn_BeginOfMonth
Return the beginning date and time of a specified month.
This function requires a valid datetime value.
select dbo.fn_BeginOfMonth(GetUTCDate())Returns: 2009-08-01 05:00:00.000
dbo.fn_BeginOfNextMonth
Return the beginning of next month.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_BeginOfNextMonth(GetUTCDate())Returns: 2009-09-01 05:00:00.000
dbo.fn_BeginOfThisMonth
Return the beginning of this month. This function has the same functionality as dbo.fn_BeginOfMonth.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_BeginOfThisMonth(GetUTCDate())Returns: 2009-08-01 05:00:00.000
dbo.fn_EndOfLastMonth
Returns the ending date and time of last month.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfLastMonth(GetUTCDate())Returns: 2009-08-01 05:00:00.000
dbo.fn_EndOfNextMonth
Returns the ending date and time of next month.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfNextMonth(GetUTCDate())Returns: 2009-10-01 05:00:00.000
dbo.fn_EndOfThisMonth
Returns the ending date and time of this month.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfThisMonth(GetUTCDate())Returns: 2009-09-01 05:00:00.000
dbo.fn_FirstDayOfMonth
Returns the first date of the month for a specified month.
This first parameter is a valid datetime value. The second parameter is the month you wish to check.
select dbo.fn_FirstDayOfMonth(GetUTCDate(), 8)Returns: 2009-08-01 00:00:00.000
dbo.fn_LastXMonth
Returns the date and time from one month ago today ( assuming 30 days ago ).
This first parameter is a valid datetime value. The second parameter is the number of months in the past.
select dbo.fn_LastXMonth(GetUTCDate(), 1)Returns: 2009-07-16 05:00:00.000
dbo.fn_NextXMonth
Returns the date and time from one month in the future – from today.
This first parameter is a valid datetime value. The second parameter is the number of months in the future.
select dbo.fn_NextXMonth(GetUTCDate(), 1)Returns: 2009-09-17 05:00:00.000
Customization, Dynamics CRM, Reporting 393 views -
CRM 4.0’s Built-in SQL Functions (Part 2 of 5)
As we continue onto the second article in our set, you may wish to review the previous article:
CRM 4.0’s Built-in SQL Functions (Part 1 of 5)
Note: The date used in the following example is 2009-08-16.
dbo.fn_BeginOfLastWeek
Returns the beginning date and time for last week.
This function requires a valid datetime value. It is assumed you will specify today’s date and time
select dbo.fn_BeginOfLastWeek(GetUTCDate())Returns: 2009-08-23 05:00:00.000
dbo.fn_BeginOfLastXWeek
Returns the beginning date and time for a week X weeks ago.
The first parameter is the date in question, the second parameter is the number of weeks before that date.
select dbo.fn_BeginOfLastXWeek(GetUTCDate(), 1)Returns: 2009-08-09 05:00:00.000
dbo.fn_BeginOfNextWeek
Returns the beginning date and time for next week.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_BeginOfNextWeek(GetUTCDate())2009-08-23 05:00:00.000
dbo.fn_BeginOfWeek
Returns the beginning date and time for a specified date.
This function requires a valid datetime value.
select dbo.fn_BeginOfWeek(GetUTCDate())2009-08-16 05:00:00.000
dbo.fn_BeginOfThisWeek
Returns the beginning date and time for this week.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_BeginOfThisWeek(GetUTCDate())Returns: 2009-08-16 05:00:00.000
dbo.fn_EndOfLastWeek
Returns the ending date and time for last week.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfLastWeek(GetUTCDate())Returns: 2009-08-16 05:00:00.000
dbo.fn_EndOfNextWeek
Returns the ending date and time for nextweek.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfNextWeek(GetUTCDate())Returns: 2009-08-30 05:00:00.000
dbo.fn_EndOfNextXWeek
Returns the beginning date and time for a week X weeks in the future.
The first parameter is the date in question, the second parameter is the number of weeks after that date.
select dbo.fn_EndOfNextXWeek(GetUTCDate(), 1)Returns: 2009-08-24 05:00:00.000
dbo.fn_EndOfThisWeek
Returns the ending date and time for this week.
This function requires a valid datetime value. It is assumed you will specify today’s date and time.
select dbo.fn_EndOfThisWeek(GetUTCDate())Returns: 2009-08-23 05:00:00.000
dbo.fn_NTDayOfWeek
Returns the day of the week. 0 = Sunday, 6 = Saturday.
select dbo.fn_NTDayOfWeek(GetUTCDate())Returns: 0 ( for Sunday )
Customization, Dynamics CRM, Reporting 617 views




