Tuesday 11 September 2012

Copying files is extremely slow to a vmware vm

Solution 1:

After installing windows 7 64bit on my computer as the host operating system, copying files from the host windows to my linux virtual machine was painfully slow. After some research I found the fix to be :
Going to the control panel -> network and internet-> network connections-> right click on your physical interface -> click on configure-> click on the advanced tab.

In here make sure ipv4 checksum offloader, large send offload v2 ipv4, large send offload v2 ipv6 are disabled.

Solution 2:

You must disable the TCP Offload Engine features in the driver on the host.

To disable the TCP Offload Engine features:
Go to Start > Run.
Type regedit and press Enter.
Browse to:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters


Create a key named DisableTaskOffload, of type DWORD.
Set the value of the key to 1 .
Close the Registry Editor and restart the computer.

Reference:

Wednesday 22 August 2012

VMWare Performance - vmem file cause harddisk IO busy

I am doing my project work on a vmware virtual machine. I normally will let the vm running over night. The issue is that the VM will hang for at least 15 min everyday morning when I wake it up.

After some investigation, I found there are huge read and write activities on the the *.vmem file in the virtual machine folder. It turns out the vmem file is the backup of your VM's memory. If your VM's memory is big, e.g. 8Gb, there will be a lot of writing to backup the memory to harddisk. 


You can change it by ask vmware to save the memory backup in your host machine's RAM. The catch is that there is no GUI to help you therefore you have to manually modify the vmx file. However it is a easy change. All you need to have is the following line in you vmx file.

mainmem.useNamedFile = "FALSE"



Sunday 20 May 2012

Prevent a large textbox from getting put on the second page in SSRS

Problem:
When I render a SSRS report in PDF and the textbox is too big or long, it puts my large textbox on the second page and leave the first page with large empty space.

Solution:
In SSRS 2008 R2 and Visual Studio 2008:
Click (not-right click) a textbox and go to the properties window (lower right side of VS) -> KeepTogether = false.
The text will cleanly cut between a line and continue on the next page.

Reference:
http://stackoverflow.com/questions/3111071/dealing-with-very-tall-textboxes-and-pagination-in-ssrs-2005

Tuesday 15 May 2012

How to disable floating tabs in Visual Studio 2010


Solution1: Ctrl+DoubleClick, it will dock back to its last position.



Solution2: The current version of Productivity Power Tools does support disabling floating tabs: it's in Options > Productivity Power Tools > Document Tab Well > Floating Docs > [ ] Enable floating tab well. Unchecking this stopped all the SSDT Juneau tabs from opening floating for me. ProductivityPower Tools



Wednesday 28 March 2012

Uses of content-disposition in an HTTP response header

Uses of content-disposition in an HTTP response header

// Download the file
Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);

// Display the file in browser
Response.AppendHeader("content-disposition", "inline; filename=" + fileName);

Reference:
http://stackoverflow.com/questions/1012437/uses-of-content-disposition-in-an-http-response-header

Monday 26 March 2012

Relative path with asp.net

The main part is to decide if it for the client side or server side which can be sometimes tricky.

Client side
A relative path that is resolved against the current page path.


A relative path that is resolved as a peer of the current page path.


Server side
ASP.NET includes the Web application root operator (~)



http://msdn.microsoft.com/en-us/library/ms178116(v=vs.90).aspx

Sunday 25 March 2012

TFS Server 2010 with Business Intelligence Studio 2008

If you have upgraded to TFS Server 2010, connectivity from Visual Studio 2008 (shell for SQL Server Business Intelligence Studio 2008) has been a problem. Please follow the steps below in order to resolve this. Note that installation order is important. If you don’t have Team Explorer installed, step 3 will skip and compatibility pack will never install!

1. Install Visual Studio 2008, if it’s not already installed. If you are using BIDS studio 2008, you will have this installed already.

2. Install Team Explorer for Visual Studio 2008, if it’s not already installed http://www.microsoft.com/downloads/en/details.aspx?familyid=0ED12659-3D41-4420-BBB0-A46E51BFCA86&displaylang=en

3. Install Visual Studio 2008 Service Pack 1 http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=fbee1648-7106-44a7-9649-6d9f6d58056e&displayLang=en

4. Install Visual Studio 2008 TFS 2010 Forward Compatibility pack http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=cf13ea45-d17b-4edc-8e6c-6c5b208ec54d

If you encounter any issues, you may want to fix the registry as suggested in the blog – http://blog.jmedved.com/2009/11/visual-studio-2008-and-team-foundation.html

Ref: http://provizinc.wordpress.com/2010/10/08/tfs-server-2010-with-business-intelligence-studio-2008/

Once you install everything, you can try adding Team Foundation Server 2010 as destination, but you will be greeted with error “TF31002: Unable to connect to this Team Foundation Server …”. Reason behind this is that old Team Explorer 2008 does not know anything about collections.

Solution would be to add it as full path (e.g “http://server:8080/tfs/collection”). I could not do it because every time I entered full path, I also got error “TF30335: The server name cannot contain characters ‘/’ or ‘:’ …”. Since official way would not work it was time to come up with alternative.

In order to add TFS 2010 server, you will need to exit Visual Studio 2008 and go into Registry editor. Find key “HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers” and at this location just add string value. Name of this value will be what Team Explorer 2008 will use for display. It’s value is full address of your server. It should be something like “http://server:8080/tfs/collection”.

Now you can go into Visual Studio 2008 and Team Explorer will have new entry. As you work with it, you will notice that not everything is “bump-free” (e.g. tasks). However, source control it self will work perfectly and that was enough for me.

Ref: http://www.jmedved.com/2009/11/visual-studio-2008-and-team-foundation-server-2010/

Indexer - Class member

Indexers are syntactic convenience that enable you to create a class, struct or interface that client application can accessed just as an array.

Static readonly vs const

The difference is that the value of a static readonly field is set at run time, and can thus be modified by the containing class, whereas the value of a const field is set to a compile time constant.

In the static readonly case, the containing class is allowed to modify it only

in the variable declaration (through a variable initializer)
in the static constructor (instance constructors, if it's not static)

http://blogs.msdn.com/b/csharpfaq/archive/2004/12/03/274791.aspx

Const values are burned directly into the call-site; this is double edged:

it is useless if the value is fetched at runtime, perhaps from config
if you change the value of a const, you need to rebuild all the clients
but it can be faster, as it avoids a method call...
...which might sometimes have been inlined by the JIT anyway
If the value will never change, then const is fine - Zero etc make reasonable consts ;-p Other than that, static properties are more common.

http://stackoverflow.com/questions/755685/c-static-readonly-vs-const

Wednesday 21 March 2012

SQL IDENTITY_INSERT

SQL IDENTITY_INSERT is allow values to be inserted into the identity column of a table.
Identity column creates a numeric sequence value for you automatic.

It only allow one table in a session can have the IDENTITY_INSERT property set to ON.
If you need to change the table, you need to set the existing table IDENTITY_INSERT back to OFF.

SET IDENTITY_INSERT TableName OFF

If the value inserted is larger than the current identity value for the table, SQL Server automatically uses the new inserted value as the current identity value.

SET IDENTITY_INSERT TableName ON

http://sqltutorials.blogspot.co.nz/2008/04/sql-identityinsert.html

Saturday 17 March 2012

Misc 18/03/2012

L'Inconnue de la Seine => Death Mask => CPR doll Resusci Anne
Gaëtan Dugas (Patient Zero of HIV of America)

Thursday 8 March 2012

To var or not to var

When to var:
* Improve readability - where the repeated type is long and complex. For example:

When not to var:
* prime types

Resharper shortcut keys PDF

http://www.jetbrains.com/resharper/docs/ReSharper60DefaultKeymap_VS_scheme.pdf

Sunday 4 March 2012

Crm 2011 Async Plugin timeout Issues

Plugins (both sync and async) are not supposed to be long-running processes and therefore there is a 2 minute timeout. I think you should reconsider your design to use a workflow (perhaps with a custom workflow activity) to solve your problem. Only workflows are allowed to execute for unlimited amount of time. However, because custom workflow activities are not supported in CRM Online you might have to consider using Azure.

Reference:
http://social.microsoft.com/Forums/sv-SE/crmdevelopment/thread/63430219-4262-47ae-8184-db1d82c4473e

Side track read: CRM 2011 Online: Why custom workflow assemblies are not supported

Saturday 3 March 2012

Pivot table definition, explaination, How to do a dynamic columned pivot table?

Pivot table does two things:
1. Aggregate on the row fields' values
2. Subcategorizing on the (pivot) column values

Three key elements:
1. row field
2. column field
3. value field

The reason the Pivot table got its name is because you take some or all the values from the column field and rotate those values to become actually columns in the pivot table.

--How to do a dynamic columned pivot table:
--The following query will run on the AdventureWorks DB of the sql 2008R2 sample Database.

DECLARE @cols nvarchar(4000);

WITH CustomerIDList
AS
(
SELECT DISTINCT TOP 100
CustomerID
FROM
Sales.SalesOrderHeader
ORDER BY
CustomerID
)

SELECT @cols = STUFF(
(SELECT
'],[' + CAST(CustomerID AS varchar)
FROM
CustomerIDList
ORDER BY
CustomerID
FOR XML PATH('')), 1, 2, '') + ']'

Print(@cols)


DECLARE @query NVARCHAR(4000)
SET @query = N'SELECT OrderYear, '+
@cols +'
FROM
(SELECT CustomerID
, DATEPART(yyyy, OrderDate) as OrderYear
, TotalDue
FROM
Sales.SalesOrderHeader
) AS orgn
PIVOT
(
MAX([TotalDue])
FOR CustomerID IN
( '+
@cols +' )
) AS pvt
'

EXECUTE(@query)

Thursday 1 March 2012

Export solution didn't export all entity properties, e.g. display in the Settings area

Question:
I have a solution that I just created a new entity in. The entity's property is set to display in the Settings area. However when I publish the solution as a managed solution to my test system, the new entity does not show up in the left menu under settings like it does on my development system. If I look at the solution properties in my test system the entity is not checked to display in the Settings area.

What would cause this property to not export/import with the solution? All my other changes appear to have imported and published OK.

Answer:
Looks like the problem was that I was not exporting the Site Map.

Ref:
http://community.dynamics.com/product/crm/f/117/p/68995/125925.aspx
https://community.dynamics.com/product/crm/crmtechnical/b/crmmitchmilam/archive/2011/12/19/developer-tip-o-the-day-solutions-and-the-sitemap.aspx

Sunday 26 February 2012

Crm 2011 Auditing Report

Unfortunately the Audit entity does not not have a Filtered view in the database. Also, there is no support for advanced find and the like.
Therefore there is no supported way to create a report that runs on the audit entity.

If you are working with Dynamics CRM 2011 On Premise you could go for the unsupported solution provided by daemon lin in this thread:
Query the table AuditBase (or the Audit view) in combination with the [MetadataSchema].[Attribute] table and the [MetadataSchema].[Entity] table to translate the AttributeMask (separated with ',') in AuditBase using Attribute.ColumnNumber = (the number in AuditBase.ChangeData), Attribute.EntityId = Entity.EntityId and Entity.ObjectTypeCode = AuditBase.ObjectTypeCode into the attribute names (You can get the display name using [MetadataSchema].[LocalizedLabel]). The corresponding changed values are in AuditBase.ChangeData seperated by ~. Operation is an optionset (1=Create, 2=Update, 3=Delete)

Note that security will NOT be applied on the data. Security Roles are not taken into account in this query. (In contrast, Filtered views always apply security for the current user)

Remember that in this case you are working in an unsupported mode and that a CRM update may break your report. Make sure to document that you did this.

If you are working with CRM 2011 Online: there is no way to create a complete report using SSRS. SSRS in CRM Online cannot directly access the database and the Audit Entity is not entirely exposed through web services which is required if you want to create a FetchXml based Report. (e.g. the ChangeData column that contains the changed data is not valid for read; you would have no easy option to translate the attributemask into corresponding field names.)

In All Cases: you can always work with filtering on the Audit Summary View (Settings > Auditing > Audit Summary View)

http://social.microsoft.com/Forums/en/crmdevelopment/thread/b3bcc68b-88e4-4c1e-af96-dc645b34bbe7

http://marcuscrast.wordpress.com/2012/01/14/dynamics-crm-2011-audit-report-in-ssrs/

http://www.avanadeblog.com/xrm/2010/09/crm-2011-feature-of-the-week-9132010-auditing.html

http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/a11cf7b2-3f5a-4f2b-b97d-9ca56a0c5aab

Saturday 25 February 2012

Crm 2011 Developer Toolkit - How to exclude a resource file from a crm deployment package?

Please note the properties window of the web resource file. If you set the Build Action to None, the resource will NOT be deployed to Crm

Friday 24 February 2012

VirtualBox 4: how to save the State of the Machine

To close virtual machine, users can simply click the x in the top right corner, or press the host key + Q.

After closing the virtual machine window, VirtualBox will ask if you want to save, send the shutdown signal, or power off the VM.

http://grok.lsu.edu/article.aspx?articleid=13463

Wednesday 22 February 2012

How to do AllColumns for ColumnSet for Crm 2011

new Microsoft.Xrm.Sdk.Query.ColumnSet(true) is equal to new AllColumns() in CRM 4.0.

Thursday 16 February 2012

How does Crm smart matching work? smart matching rules and logic

How does smart matching work:

Smart matching relies completely on the existence of similarity between emails. The subject and recipients (from, to, cc and bcc) list are the two important components that are considered with checking for similarity.

When an email is sent from CRM, there are two sets of hashes generated for it and stored in the database.

a. Subject hashes:

To generate subject hashes, the subject of the email, which may include the CRM token if its usage is enabled in system settings, is first checked for noise words like RE: FW: etc. The noise words are stripped off the subject and then tokenized. All the non empty tokens (words) are then hashed to generate subject hashes.

b. Recipient hashes:

To generate the recipient hashes the recipient (from, to, cc, bcc) list is analyzed for unique email addresses. For each unique email address an address hash is generated.

Next when an incoming email is tracked (arrived) in CRM, the same method is followed to create the subject and recipient hashes.

To find the correlation between the incoming email and the outgoing email the stored subject and recipient hashes are searched for matching values. Two emails are correlated if they have the same count of subject hashes and at least two matching recipient hashes.

http://community.dynamics.com/roletailored/customerservice/b/cscrmblog/archive/2008/11/11/microsoft-dynamics-crm-email-correlation-and-smart-matching.aspx

http://blogs.msdn.com/b/crm/archive/2008/01/29/what-s-new-in-microsoft-dynamics-crm-4-0-e-mail-integration.aspx

Tuesday 14 February 2012

CRM 2011 How to change ownership of an entity after creation. Clone an entity

Issue:

Has anyone tried changing the ownership type of an entity from organisation to user in CRM 2011 before?

As there are hundreds of fields on the entities’ form already, I’d like to save time on recreating entity if possible.

Solution:

You could export all the entity fields and re-import them to the new user-owned entity, creating them during import. Far quicker than doing it manually.

Step1: Create the entity first without adding any fields and select the entity type to be either org or user.

Step2: Using data import wizard (NOT solution import) to create the rest of the fields. Be careful with the Guid in the lookup fields. They have to exist in the target crm org.

Step3: Tidy up the forms

http://www.youtube.com/watch?v=hZVFXFZ5tUU

Monday 13 February 2012

Html5 vs Silverlight

Small outward facing apps, go HTML, for complex LOB go silverlight.

http://www.hanselman.com/blog/ShouldIUseHTML5OrSilverlightOneMansOpinion.aspx

Sunday 12 February 2012

Out of the mouths of children

A 1st grade school teacher had twenty-six students in her class. She presented e...ach child in her classroom the 1st half of a well-known proverb and asked them to come up with the remainder of the proverb. It's hard to believe these were actually done by first graders

Friday 10 February 2012

Where is my app.config for SSIS?

Where is my app.config for SSIS?
By Darren Green 3 Aug 2009 09:20
Sometimes when working with SSIS you need to add or change settings in the .NET application configuration file, which can be a bit confusing when you are building a SSIS package not an application. First of all lets review a couple of examples where you may need to do this.

You are using referencing an assembly in a Script Task that uses Enterprise Library (aka EntLib), so you need to add the relevant configuration sections and settings, perhaps for the logging application block.
You are using using Enterprise Library in a custom task or component, and again you need to add the relevant configuration sections and settings.
You are using a web service with Microsoft Web Services Enhancements (WSE) 3.0 and hosting the proxy in SSIS, in an assembly used by your package, and need to add the configuration sections and settings.
You need to change behaviours of the .NET framework which can be influenced by a configuration file, such as the System.Net.Mail default SMTP settings. Perhaps you wish to configure System.Net and the httpWebRequest header for parsing unsafe header (useUnsafeHeaderParsing), which will change the way the HTTP Connection manager behaves.
You are consuming a WCF service and wish to specify the endpoint in configuration.
There are no doubt plenty more examples but each of these requires us to identify the correct configuration file and and make the relevant changes. There are actually several configuration files, each used by a different execution host depending on how you are working with the SSIS package.

The folders we need to look in will actually vary depending on the version of SQL Server as well as the processor architecture, but most are all what we can call the Binn folder. The SQL Server 2005 Binn folder is at C:\Program Files\Microsoft SQL Server\90\DTS\Binn\, compared to C:\Program Files\Microsoft SQL Server\100\DTS\Binn\ for SQL Server 2008. If you are on a 64-bit machine then you will see C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\ for the 32-bit executables and C:\Program Files\Microsoft SQL Server\90\DTS\Binn\ for 64-bit, so be sure to check all relevant locations. Of course SQL Server 2008 may have a C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\ on a 64-bit machine too.

To recap, the version of SQL Server determines if you look in the 90 or 100 sub-folder under SQL Server in Program Files (C:\Program Files\Microsoft SQL Server\nn\) . If you are running a 64-bit operating system then you will have two instances program files, C:\Program Files (x86)\ for 32-bit and C:\Program Files\ for 64-bit. You may wish to check both depending on what you are doing, but this is covered more under each section below.

There are a total of five specific configuration files that you may need to change, each one is detailed below:

DTExec.exe.config

DTExec.exe is the standalone command line tool used for executing SSIS packages, and therefore it is an execution host with an app.config file.

e.g. C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTExec.exe.config

The file can be found in both the 32-bit and 64-bit Binn folders.

DtsDebugHost.exe.config

DtsDebugHost.exe is the execution host used by Business Intelligence Development Studio (BIDS) / Visual Studio when executing a package from the designer in debug mode, which is the default behaviour.

e.g. C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DtsDebugHost.exe.config

The file can be found in both the 32-bit and 64-bit Binn folders. This may surprise some people as Visual Studio is only 32-bit, but thankfully the debugger supports both. This can be set in the project properties, see the Run64BitRuntime property (true or false) in the Debugging pane of the Project Properties.

dtshost.exe.config

dtshost.exe is the execution host used by what I think of as the built-in features of SQL Server such as SQL Server Agent

e.g. C:\Program Files\Microsoft SQL Server\90\DTS\Binn\dtshost.exe.config

This file can be found in both the 32-bit and 64-bit Binn folders

devenv.exe.config

Something slightly different is devenv.exe which is Visual Studio. This configuration file may also need changing if you need a feature at design-time such as in a Task Editor or Connection Manager editor.

Visual Studio 2005 for SQL Server 2005 - C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe.config
Visual Studio 2008 for SQL Server 2008 - C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe.config
Visual Studio is only available for 32-bit so on a 64-bit machine you will have to look in C:\Program Files (x86)\ only.

DTExecUI.exe.config

The DTExec UI tool can also have a configuration file and these cab be found under the Tools folders for SQL Sever as shown below.

C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\DTExecUI.exe
C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\DTExecUI.exe

A configuration file may not exist, but if you can find the matching executable you know you are in the right place so can go ahead and add a new file yourself.

In summary we have covered the assembly configuration files for all of the standard methods of building and running a SSIS package, but obviously if you are working programmatically you will need to make the relevant modifications to your program’s app.config as well.

Ref: http://www.sqlis.com/post/Where-is-my-appconfig-for-SSIS.aspx

Thursday 9 February 2012

Dates Fields and Time Zones in CRM

As we pick up larger projects, we are finding more that cross international boundaries. Due to the way SQL handles date fields and how the CRM import process works, this presents some problems. Here is the summary of my findings on these issues.

Server time – this is the timezone of the server. So if you server is installed in NZ, you will be in GMT+12
User time – this is set in the user’s CRM options


Daylight saving – note that to make this email simpler, I have ignored daylight saving. When you are working out time adjustments, you will need add time on appropriately. Daylight saving varies by country and even within countries e.g. Queensland does not have it but NSW in the same timezone does.

1. Populating a date and time field through the UI
Date and time is entered as user’s local time and stored as UTC in the database. When viewed by a user, this is converted to the user’s time zone. This means that if you are an NZ user (GMT+12) and you add an appointment for 1100 NZ time, it will appear as 0900 NZ time to a user in the Sydney timezone (GMT+10). So far, so good.

Resolution: No required, working as expected


2. Populating a date only field through the UI
SQL does not have the concept of a date only and has to store date and time for date only record entered in CRM. It does this by storing the date at midnight local time. This means that if a NZ user (GMT+12) adds a date of 09/02/2011, it will be stored in SQL as 2011-02-08 12:00:00 (midday the day before) so that when you add on the 12 hours, it becomes 2011-02-09 00:00:00. Now, if this date is viewed by someone in the Sydney timezone (GMT+10), it will be converted to their local time by adding on 10 hours to give 2011-02-08 22:00:00 which when you display as a date only field shows as 08/02/2011 – the day before the date entered. In summary:

Date Entered by First User (dd/mm/yy) Time Zone of First User (GMT+no.of hours) Date and Time Stored in SQL Time Zone of Second User (GMT+no.of hours) Date and Time as Converted from SQL time Date Displayed in CRM for Second User
09/02/2011 12 08/02/2011 12:00:00 10 08/02/2011 22:00:00 08/02/2011

Therefore, whenever your timezone is ahead of someone else’s, the date only field when viewed by the other user will always display the previous day (as any number of hours subtracted off of midnight will always be the previous day). This will only be a problem where dates entered in one time zone need to be viewed in another. For example, if an admin in NZ adds Christmas Day to all calendars, it will be on 25 December in NZ and 24 December for everyone else. Note that anyone whose time zone is ahead of yours will always have the correct day (as you will never have to add on more than 24 hours).

Resolution: If the data can be entered locally then you will not experience this issue. If the data must be entered from another time zone, then you will need a plugin on the record to convert the date and time to equivalent of 11pm NZ time (see 4 below for why we use 11pm). Note that the user will never see the time component as this field is displayed as date only in CRM.


3. Populating a data and time field using data import
When importing data, CRM uses the zone of the user importing the data.

Resolution: The simplest fix is to change the timezone of the user importing the records and limiting the records to a single timezone. If you need to add multiple records across time zones in one load (e.g. when loading appointment data for all of Australia), you will need to convert the time to as it would appear in the loading user’s local time. For example, if you are a NZ user (GMT+10) and want to load an appointment for a Sydney user (GMT+10) to show in their calendar from 1000 to 1100, you will need to import it as 1300 to 1400 (the GMT+12 equivalent time). See 4 below if you want to know how to add or subtract hours from a field in Excel.


4. Populating a date only field using data import
If your user is in NZ and you are loading data for any other timezone than it will display the previous day (same logic as 2 above). If, for example, you are loading sales records for Australia which use a date-only transaction date to your NZ based server, then when these records are viewed by an Australian user, they will show a day earlier. The same problem will exist when you run reports – transactions listed on the 1st of a month will get moved to the previous month – which will mean all your figures are slightly out.

Resolution: If a field is configured as date only in CRM, you can still load a time component to this field. For New Zealand, you should add 23 hours so that no matter how many hours you are behind NZ, a date only field will always show the same date (even when adjusted for Daylight Saving although this is not included below).

Hawaii US West Coast (e.g. Redmond) US East Coast (e.g. New York) London Hong Kong Sydney NZ
GMT-9 GMT-8 GMT-5 GMT+0 GMT+8 GMT+10 GMT+12
2:00 3:00 6:00 11:00 19:00 21:00 23:00
Incidentally, If anyone needs me to fly out to Hawaii to rectify time zone issues, I’ll make myself available 

To convert a date field in Excel, first format it to a custom formatting of ”dd/mm/yyyy hh:mm:ss”, then use the formula “=[Date Field] + Time (23,0,0)” where [Date Field] is the reference to the field to which you want to add time. A date that started out as 09/02/2011 will then end up as 09/02/2011 11:00:00 p.m. If you are saving your data as a CSV file, you must ensure the formatting is

Note that if you are in any other timezone, the no of hours to add is the number of hours you are ahead of the international date line minus 1

===============
Hi B,

Thanks for a great summary of the date headaches and possible solutions.

Given the problems with them I’m struggling to think of a reason why you would want to design a globalised system to record a date only and not the date and time.

Say that I am a resource NZ and I’m celebrating Christmas then someone in UK will want to know that I’m not available (a.k.a drunk) between midday of the 24rd until midday 25th UK time, not that it is Christmas day on that day. Also if someone in the UK wanted to send me a birthday wishes email they would need to be reminded to send it the day before to reach me in NZ on my Birthday.

Similarly for a deadline, if a task needs to be completed by Wednesday and the task creator is in NZ, then from their perspective the task should be completed by COB Wednesday NZ time regardless of where the task is being carried out. So while is tempting to make the due date Wednesday the task should have a due date-time of Wednesday at 5.30pm in NZ and Wednesday 3.30pm in the Oz. It is tempting to

Also if I understand you solution of adding 11 hours correctly, it will only work for countries that are further east on the globe than GMT + 2, fine for Oz but not ok for the west of this line UK, USA etc.

Cheers
A

=================
Hi A,

I agree that specific tasks which need completed at a specific time should always be date and time.

With the Christmas Day example, to mark this in everyone’s calendar correctly, you would need to create one entry for every timezone called NZ Christmas, NSW Christmas, Queensland Christmas, SA/NT Christmas, WA Christmas etc and you would either need to convert all times to NZ equivalent time or change your timezone before creating each of these if adding them as date only.

The problems occur when you have a global system which is administered and maintained out of one country (and NZ is the worst case scenario). For example, we have to load sales data with a date only field (customer does not have sales time, only date and has no interest in seeing a time field) for all global markets from NZ. These have to be manipulated to show on the correct date for the timezone.

You don’t add on 11 hours, you add on 23 hours, to make it 11pm as per my example below.

Kind regards,

B

Source - Intergen

Wednesday 8 February 2012

programming scenarios

Since I really bad at creating scenarios, I'm going to make a collection here.

Crm scenarios:
* Update Next Birthday Using a Custom Workflow Activity.
* Create URL link using a custom WF step.
* Validate SSN (social security number) using javascript
* When an account's business phone number changed, all its child contact record need to be updated on that field too.

When to use workflow and when to use plugin

Use workflow when the business logic must be performed by people who are not developers.

Use workflow when you need the ability to allow user to start a business logic manually.

Use Plugin when the delay between when the event occurs and when the business logic runs is NOT acceptable.

Saturday 4 February 2012

Crm 2011 Sdk helper code summary

ServerConnection class: Frequently used. This class can held information needed to help you connect to and authenticate with Dynamics CRM 2011 using the OrganizationServiceProxy and DiscoveryServiceProxy classes.

DeviceIdManager class: Sometimes used. This class registers a computing device with Windows Live ID. This class is only needed when authenticating with Dynamics Crm Online

SystemUserProvider class: Rarely used. The purpose of this class is to create users in AD and Dynamics Crm 2011

Enumeratoins for Options Sets: Often used. These enumerations can be generated from the CrmSvcUtil code generation tool.

--------The SDK description---------
ServerConnection class:
The ServerConnection class provides methods to obtain server, organization, and user logon information for any Microsoft Dynamics CRM deployment. This information is needed to connect to and authenticate with Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online using the DiscoveryServiceProxy and OrganizationServiceProxy classes. The ServerConnection class is used by most samples that ship with the Microsoft Dynamics CRM 2011 SDK.

DeviceIdManager class:
The DeviceIdManager class registers a computing device with Windows Live ID, through the generation of a device ID and password, and optionally stores that information in an encrypted format on the local disk for later reuse. This functionality is required when authenticating with Microsoft Dynamics CRM Online. The device registration is stored in the %USERPROFILE%\LiveDeviceID folder on the computing device.

The primary class method to call from your code is LoadOrRegisterDevice. For an example of how the DeviceIdManager class is used, see the GetDeviceCredentials method in the Helper Code: ServerConnection Class topic.

A Windows Azure hosted application that must authenticate with Microsoft Dynamics CRM Online should either set the PersistToFile property of DeviceIdManager to false or call the two parameter LoadOrRegisterDevice method passing in the required device ID and password. In both cases, the DeviceIdManager will not attempt to persist the device ID and password to a file.

SystemUserProvider class:
The SystemUserProvider class demonstrates how to programmatically create additional users in Active Directory and Microsoft Dynamics CRM 2011.

Several SDK samples require additional (fictitious) system users to exist in Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online, other than the logged on user, for the sample to perform its intended task. For Microsoft Dynamics CRM 2011, these samples use the SystemUserProvider class methods to create these additional required users. Since it currently is not possible to programmatically create a new Windows Live ID user, when running against a Microsoft Dynamics CRM Online server, the code just prints the required user information to the console. You can then manually add and invite those users if desired.

Enumeratoins for Options Sets:
The SDK download package includes an extension to the CrmSvcUtil code generation tool that you can use to generate enumerations for all option set values including global option sets, picklist, state, and status values. For more information, see Sample Extension to Generate Enumerations for Option Sets.

Create a Crm console app from scratch 2. A quick startup program

When writing an application that uses the Microsoft Dynamics CRM SDK, you typically need to perform the following steps to configure your application’s project.

In the project’s properties, set the target framework to .NET Framework 4.

Add the following .NET references to your project:

System.Data.Linq

System.Runtime.Serialization

System.Security

System.ServiceModel

System.DirectoryServices.AccountManagement


Add the required Microsoft Dynamics CRM SDK assembly references. At a minimum, add Microsoft.Crm.Sdk.Proxy and Microsoft.Xrm.Sdk. For a complete list of the assemblies included in the Microsoft Dynamics CRM SDK, see Assemblies Included in the Microsoft Dynamics CRM SDK.


In most cases, you need to install Windows Identity Foundation and add a reference to Microsoft.IdentityModel to your project.

Including the following namespaces
using System;
//using System.ServiceModel; // Maybe needed for more complex crm programs
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
//using Microsoft.Crm.Sdk; // Maybe needed for more complex crm programs
using Microsoft.Crm.Sdk.Messages;

using System;
//using System.Collections.Generic;
//using System.Text;
//using System.ServiceModel;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
//using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Messages;

namespace CrmConsoleApplication2
{
    public class Program
    {
        private static ClientCredentials _clientCreds;
        private static OrganizationServiceProxy _serviceProxy;

        public static void Main(string[] args)
        {
            _clientCreds = new ClientCredentials();
            _clientCreds.Windows.ClientCredential.UserName = "Administrator";
            _clientCreds.Windows.ClientCredential.Password = "NotTheRealPassword";
            _clientCreds.Windows.ClientCredential.Domain = "PLAYGROUND";

            using (_serviceProxy = new OrganizationServiceProxy(new Uri("http://localhost:5555/CRM2011RTM/XRMServices/2011/Organization.svc")
                , null
                , _clientCreds
                , null))
            {
                WhoAmIRequest request = new WhoAmIRequest();
                WhoAmIResponse response = (WhoAmIResponse)_serviceProxy.Execute(request);
                Console.WriteLine("User {0} has just connected", response.UserId);
            }

            Console.ReadLine();
        }
    }
}

#Use the Sample and Helper Code

Thursday 2 February 2012

Microsoft Dynamics CRM 2011 – Error When Browsing Discovery.svc Service

Reference
http://yellowduckguy.wordpress.com/2012/02/03/microsoft-dynamics-crm-2011-error-when-browsing-discovery-svc-service/

Today I had to resolve a customer issue where the Dynamics CRM 2011 for Outlook Configuration Wizard could not find the CRM 2011 server and the CRM server did exist on the domain.



I was connecting Microsoft Outlook 2007 to CRM 2011 via the installed add-in Microsoft Dynamics CRM 2011 for Outlook.

My list of areas to troubleshoot this issue was as follows:
•Check CRM 2011 server is running ok. Can I browse it from the CRM Server?
•Check I can ping the CRM server from the Outlook client PC
•Check I can browse to CRM from the web browser on the Outlook client PC
•Check I can resolve the Discovery.svc service. CRM for Outlook Configuration tool uses this.
•Check the registry settings for the Configuration settings of CRM for Outlook

The Issue
Going through this list I found I could not resolve the Discovery.svc service from the Outlook client PC. You should be able to resolve the Discovery.svc service using the following URL. http://[yourcrmserver]/XRMServices/2011/Discovery.svc You should see a page similar to below when you can successfully render the Discovery Service.

So I thought I had a possible IIS issue as I couldn’t render the service on the CRM server as well. I decided to check the Event Viewer first for any clues. Below is the error message I received.

WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/63835064
Exception: System.ServiceModel.ServiceActivationException: The service ‘/XRMServices/2011/Discovery.svc’ cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting ‘system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled’ to true or specifying ‘system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters’.
Parameter name: item. —> System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. If your service is being hosted in IIS you can fix the problem by setting ‘system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled’ to true or specifying ‘system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters’.
Parameter name: item
at System.ServiceModel.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item)
at System.Collections.Generic.SynchronizedCollection`1.Add(T item)
at System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses)
at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
at Microsoft.Crm.Sdk.V5.DiscoveryServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
— End of inner exception stack trace —
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
Process Name: w3wp
Process ID: 4116
From this error message it seems their is a http bindings issue within IIS. Then it came to me! One of our infrastructure guys had created another port binding for CRM to be on port 80 for some other unrelated testing.
Resolution
Therefore to resolve this I had to remove the extra http binding in the Microsoft Dynamics CRM website within IIS. To change or investigate your site bindings, click on
Bindings…
under
Edit Site
in IIS as shown below.

You should only have one http binding in the list as shown below. Note: I have removed the binding which was causing the problem in the image below.

Its possible to have multiple http bindings, but you will need to change some web.config values which contain
multipleSiteBindingsEnabled
and set it to
true
. See the error message earlier for more information. Hope that helps! Greg Olsen

Tuesday 31 January 2012

Leaving Intergen

Crm 2011 UI Terminology. Application and Entity form screen regions

Application Screen Regions

Entity Form Screen Regions

Increase the Maximum Records exported to Excel

There are two ways to achieve it.

Method 1: Use Dynamic Excel spreadsheet
1) Select the view list you want to export. For example: Active Contacts.

2) Click Excel from the list toolbar and select Dynamic Worksheet option

3) Open the excel workbook and enable Data Connection if required

4) On the excel workbook, right click the data area, select Edit Query

5) If there is a pop-up windows about "The query cannot be edited by the Query Wizard", click ok. Now you will see the Microsoft Query window.

6) From the Microsoft Query toolbar, click View and select SQL. A new pop-up Windows showing the actual SQL statement appears.

7) Remove Top 10000 from the SQL statement and click OK to exit the SQL statement window

8) From the Microsoft Query window toolbar, click File and select Return Data to Microsoft Office Excel

9) Refresh your excel worksheet if auto-refresh is not enabled and you should see all data from the select CRM view now

Ref: http://usingmscrm.blogspot.co.nz/2009/09/export-to-excel-only-showing-10-000.html

Method 2: Change settings in CRM SQL Database
Follow the steps below to make the change at the database level in CRM 4.0. Maybe CRM 2011 as well.

Open SQL Mangement Studio
Use the _MSCRM database
Open the OrganizationBase table
Locate the column – MaxRecordsForExportToExcel
Change the value to the new value

Ref: http://www.powerobjects.com/blog/2010/03/29/increase-the-maximum-records-exported-to-excel/
http://support.microsoft.com/kb/911395

Credit to Elaiza Benitez

When you export plugin, you need to export plugin's steps too.

When you export plugin, you need to export plugin's steps too. The steps are called Sdk Message Processing Steps.

Plugin Deployment in CRM 2011 - Best Practices

http://crmdm.blogspot.co.nz/2011/03/plugin-deployment-in-crm-2011-best.html

Monday 30 January 2012

Microsoft Dynamics CRM: Workflow Authoring Best Practices

The Microsoft Dynamics CRM workflow engine provides powerful functionality for implementing custom business logic in a CRM deployment. However, it also lends itself to complex problems and design mistakes which can result in expensive maintenance and confused users. This article explains in detail a few important considerations when implementing workflows and custom workflow activities in CRM.

1. Composition with child workflows.

The workflow pattern is in general one of composition of smaller steps. Therefore, when creating a workflow, think about which parts of the workflow can be generalized as a "sub-process" and be reused in multiple workflow definitions. By isolating these smaller processes, one can define child workflows which can then be called from multiple workflow definitions. The advantage is that the child workflow can be easily modified as opposed to modifying multiple workflow definitions. It will also make it simpler to define future workflows that might be a composition of smaller processes or business logic. One important consideration is that child workflows are executed asynchronously with respect to the parent workflow. Therefore, you should not make use of child workflows for sub-processes which require sequential execution.

2. Awareness of persistence points in workflow definitions.

If you have a long workflow that might take a long time to execute you will need to consider whether the workflow will persist and what that implies. A workflow can be persisted because of multiple reasons: The workflow instance is waiting for some event to occur, the CrmAsyncService is stopped or the workflow instance explicitly requests to be persisted by executing an activity with the PersistOnCloseAttribute. In any case, the workflow engine unloads the workflow instance and persists it to the database until a user manually resumes the workflow or an event occurs which resumes the workflow automatically. The important considerations are

1) At what point does the workflow persist? The workflow will persist up to the step when the last activity is marked as a persistence point. Therefore, when it resumes, it will re-execute all the steps after the last persistence point. This is important if you have logic in your workflow which you want to guarantee does not execute more than once. Note that workflow instances are automatically persisted after the following CRM steps: create, update, send email, send email from template, assign, change status, child workflow and stage. For custom activities you can add [PersistOnClose] attribute to the activity class. (see http://msdn.microsoft.com/en-us/library/system.workflow.componentmodel.persistoncloseattribute.aspx).

2) When is the workflow going to resume? If the workflow will wait on an event that might never happen or take years to occur, then the database will soon contain thousands of waiting workflows which could affect performance. You should consider a design in which this situation is minimized. For example a workflow that waits on an opportunity to be marked as “won” can wait forever and the condition never meets. Instead wait on the opportunity to be closed and then check the status reason once it is marked as closed; if it was not marked as “won” you might want to add a Stop Workflow step at that point.

3. Write "atomic" custom activities.

Custom workflow activities should not implement the entire logic of the workflow, they are ideally small "atomic" steps that will make part of larger workflows. Because custom activities don't have the ability to control persistence, they should never cause the workflow to go idle or persist in the middle of a custom activity. Generally, it is better to have multiple custom activities that are called in sequence from a parent workflow than one large custom activity that implements all the logic in sequence. This also follows from the principle of workflow as a composition pattern. For example if your process is to take custom actions A, B and C when an account is opened, it is generally better to write a custom activity for each A, B and C separately and add a step for each activity in your workflow as opposed to writing a custom activity that implements A, B and C sequentially and then add a single step to the workflow to include this custom activity.

4. Correct use of "Execution Time".

The CRM workflow designer provides a property called "Execution Time" which can be used in dynamic expressions such as "if Account(CreatedOn) + 10 days < workflow(ExecutionTime)". The meaning of this property is neither the time at which the workflow is published nor the time the workflow instance starts. The actual value of this property is the real time when the workflow evaluates an expression that contains this property. Therefore, expressions such as "Wait until 1 day after workflow(ExecutionTime)" will never succeed and the workflow will wait and resume once a day forever causing performance problems. If you want your workflow to wait for a specific amount of time you should use the wait step and configure the condition as: workflow – timeout – equals – {Duation}. This will unload the workflow and resume execution after the specified time duration has passed. 5. Plugins Vs. Workflows. This is a common dilemma in CRM and there is no exact formula to find the best implementation method for a specific situation. However, this article provides some general rules of thumb that can be used to decide whether to use a plugin or a workflow: http://blogs.msdn.com/lezamax/archive/2008/04/02/plug-in-or-workflow.aspx Ref: http://blogs.msdn.com/b/crm/archive/2010/01/15/microsoft-dynamics-crm-workflow-authoring-best-practices.aspx

Correct use of "Execution Time"

The CRM workflow designer provides a property called "Execution Time" which can be used in dynamic expressions such as "if Account(CreatedOn) + 10 days < workflow(ExecutionTime)". The meaning of this property is neither the time at which the workflow is published nor the time the workflow instance starts. The actual value of this property is the real time when the workflow evaluates an expression that contains this property. Therefore, expressions such as "Wait until 1 day after workflow(ExecutionTime)" will never succeed and the workflow will wait and resume once a day forever causing performance problems. If you want your workflow to wait for a specific amount of time you should use the wait step and configure the condition as: workflow – timeout – equals – {Duation}. This will unload the workflow and resume execution after the specified time duration has passed.

Reference
http://blogs.msdn.com/b/crm/archive/2010/01/15/microsoft-dynamics-crm-workflow-authoring-best-practices.aspx

Sunday 29 January 2012

Create a Crm console app from scratch.

*Set the project's Target framework to be .Net Framework 4.

*To interact with Crm 2011 API, you can either refer to CRM 2011 sdk binary files or Service Reference
+ If you want to use sdk binary files: Include the
Microsoft.Crm.Sdk.Proxy.dll
Microsoft.Xrm.Sdk.dll in project reference
System.Security
System.Runtime.Serialization
and System.ServiceModel (This is for using WCF)

+ If you want to use Service Reference: Download the Organization Service endpoint from the Crm Developer Resources page.

*Reference the namespaces in the code.
using System.ServiceModel; // For using the WCF
using System.ServiceModel.Description; // You need this to use the ClientCredential class.
//Contains enumerations of possible picklists and integer values for some attributes.
//The naming convention of the classes is to make it easier to locate the specific attribute.
using Microsoft.Crm.Sdk;
//Defines the data contracts for attribute types, interfaces for authoring plug-ins,
//and other general purpose xRM types and methods.
using Microsoft.Xrm.Sdk;
//Defines classes for use by client-code, including a data context,
//proxy classes to ease the connection to Microsoft Dynamics CRM, and the LINQ provider.
using Microsoft.Xrm.Sdk.Client;
// Defines request/response classes for Create, Retrieve, Update, Delete, Associate , Disassociate, and the metadata classes.
using Microsoft.Xrm.Sdk.Messages;
// Defines query classes required to connect to Microsoft Dynamics CRM.
using Microsoft.Xrm.Sdk.Query;
Microsoft.Crm.Sdk.Messages;

The namespaces required for doing a WhoAmIRequest are Microsoft.Crm.Sdk, Microsoft.Xrm.Sdk.Client, Microsoft.Crm.Sdk.Messages, System.ServiceModel, System.ServiceModel.Description.

* Include the deviceidmanager.cs file in the project for authentication. Your can find the class in the crm sdk helper folder \\SDK CRM 2011\sdk\samplecode\cs\helpercode\deviceidmanager.cs.
+ Also include the Microsoft.Crm.Services.Utility namespace.

* Setup the credential which will be used to connect to Crm WCF endpoint

* Connect to WCF endpoint

* Require early bound type support

* Do something with theh endpoint


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel; // For using the WCF
using System.ServiceModel.Description;
// Contains enumerations of possible picklists and integer values for some attributes. 
// The naming convention of the classes is [open arrow brace]entityname[close arrow brace][open arrow brace]attributename[close arrow brace] to make it easier to locate the specific attribute.
using Microsoft.Crm.Sdk;
// Defines the data contracts for attribute types, interfaces for authoring plug-ins, 
// and other general purpose xRM types and methods.
//using Microsoft.Xrm.Sdk;
// Defines classes for use by client-code, including a data context, 
// proxy classes to ease the connection to Microsoft Dynamics CRM, and the LINQ provider.
using Microsoft.Xrm.Sdk.Client;
// Defines request/response classes for Create, Retrieve, Update, Delete, Associate , Disassociate, and the metadata classes.
//using Microsoft.Xrm.Sdk.Messages;
// Defines query classes required to connect to Microsoft Dynamics CRM.
//using Microsoft.Xrm.Sdk.Query;
using Microsoft.Crm.Services.Utility;
using Microsoft.Crm.Sdk.Messages;


namespace CrmConsoleApplication1
{
    class Program
    {
        private static OrganizationServiceProxy _serviceProxy;
        private static ClientCredentials _clientCreds;
        //private static ClientCredentials _deviceCreds;

        static void Main(string[] args)
        {
            // Setup credential
            _clientCreds = new ClientCredentials();
            _clientCreds.Windows.ClientCredential.UserName = "Administrator";
            _clientCreds.Windows.ClientCredential.Password = "NotTheRealPassword";
            _clientCreds.Windows.ClientCredential.Domain = "PLAYGROUND";
            // The DeviceIdManager class registers a computing device with Windows Live ID, through the generation of a device ID and password, 
            // and optionally stores that information in an encrypted format on the local disk for later reuse.
            // This will fail here as this vm don't have access to the Internet therefore there is no way for it to generate a device ID with login.live.com
            //_deviceCreds = DeviceIdManager.LoadOrRegisterDevice();

            // Connect to Crm WCF endpoint
            using (_serviceProxy = new OrganizationServiceProxy(new Uri("http://localhost:5555/CRM2011RTM/XRMServices/2011/Organization.svc"),
                                                                null,
                                                                _clientCreds,
                                                                null))
            {
                // require early bound type support
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

                OrganizationServiceContext orgContext = new OrganizationServiceContext(_serviceProxy);
                WhoAmIRequest request = new WhoAmIRequest();
                WhoAmIResponse response = (WhoAmIResponse)orgContext.Execute(request);
                Console.WriteLine("Your Crm user Guid is {0}", response.UserId);
            }

            Console.Read();
        }
    }
}

Saturday 28 January 2012

CRM 2011: IntelliSense for Xrm.Page

http://www.patrickverbeeten.com/pages/ContentItemPage.aspx?id=31&item=118&p=true

In CRM 2011 Javascript is no longer embedded in forms but now has build in feature to use external resource files. You can edit these files using the web browser or in an external editor. Visual studio supports Intellisense for JavaScript, this explains how enable the support for the CRM provided objects such as the Xrm.Page object to be shown.
To enable this support Visual Studio needs a reference to base the IntelliSense. First you need to download the reference file XrmPage-vsdoc.js (right click and choose save). Save this file on a convinient location. Now you can create a new js file in Visual Studio then add the following line to the top of this file:
///
The path to the file can either be relative or absolute, in this example the reference file is placed in a folder named IntelliSense in the folder where the new web resource js file is saved.

I have only tried this file with Visual Studio 2010. If there are any function which are incorrect or other errors please let me know.
This file is distributed as Freeware for details see here or the license contained in the file.

On this site http://crm2011snippets.codeplex.com you can download a set of snippets to automate common functions for JavaScript used with CRM.

Thursday 26 January 2012

ClickDimensions - Marketing addon for Crm.

I attended a ClickDimensions webinar today. They had a quite interesting product focus on marketing. Some highlights, you can use their product to create marketing email, web/portal forms, portal surveys. Their product can also track on who viewed your links in the email you sent and on your portal pages. The tracking is impressive and a bit scary. Their email template is definitely a step up from the out of box email template. Have a look at the links below.

However I think they are still lacking of features for facebook, twitter and other social tools.


Recorded and weekly webinars
http://www.clickdimensions.com/webinar/

How to Guides
http://www.clickdimensions.com/support/guides.asp

Wednesday 25 January 2012

Restaurants

Crazy horse
Red Hill

How to change crm 2011 online session timeout?

(On the ADFS server?)Open a Windows PowerShell window with Administrative Rights.
PS > Add-PSSnapin Microsoft.Adfs.PowerShell
PS > Get-ADFSRelyingPartyTrust -Name:”relying_party“
PS > Set-ADFSRelyingPartyTrust -TargetName “your_relying_party_name” -TokenLifetime 7200
So this code set the session timeout as 12 Hours (7200 minutes )
Don’t forget to replace your_relying_party_name with the real name in your AD FS 2 Manager –>Relying Party Trusts

http://www.interactivewebs.com/blog/index.php/server-tips/your-session-in-microsoft-dynamics-crm-is-about-to-expire-crm-2011-extend-session-time/

http://www.isvlabs.com/2011/11/how-to-set-dynamics-crm-2011-ifd-session-timeout/

Tuesday 24 January 2012

CRM Plugin Registration Tool restrictions and limitations

* Import solutions will not work for steps. You will get a plugin not found error. Even when the "Ignore Id's in Import Xml" option is ticked. Import solution will ONLY work for images.

Why set up UAT as a different organization is a bad idea

* Can not test rollups
* Can not test and turn tracing on if you got an execution error on UAT

Friday 20 January 2012

It is possible to debug a database deployed plug-in.

It is possible to debug a database deployed plug-in. The compiled plug-in assembly’s .pdb file must be copied to the server’s \Server\bin\assembly folder and IIS must then be restarted. After debugging has been completed, you must remove the .pdb file and reset IIS to prevent the w3wp.exe process from consuming additional memory.

Unit Testing Principles

General Principles

Test anything that might break.
Test everything that does break.
New code is guilty until proven innocent.
Write at least as much test code as production code.
Run local tests with each compile.
Run all tests before check-in to the repository.
Questions to Ask

If the code ran correctly, how would I know?
How am I going to test this?
What else can go wrong?
Could this same kind of problem happen anywhere else?
What to Test: Use Your “Right BICEP”

Are the results right?
Are all the boundary conditions CORRECT?
Can you check inverse relationships?
Can you cross-check results using other means?
Can you force error conditions to happen?
Are performance characteristics within bounds?
Good tests are “A TRIP”

Automatic
Thorough
Repeatable
Independent
Professional
CORRECT Boundary Conditions

Conformance: Does the value conform to an expected format?
Ordering: Is the set of values ordered or unordered as appropriate?
Range: Is the value within reasonable minimum and maximum values?
Reference: Does the code reference anything external that isn’t under direct control of the code itself?
Existence: Does the value exist (for example, is non-null, non-zero, present in a set, and so on)?
Cardinality: Are there exactly enough values?
Time (absolute and relative): Is everything happening in order? At the right time? In time?

Wednesday 18 January 2012

Business card scanner for CRM

Business card scanner for CRM

- Cardiris Corporate 5 for Ms Dynamics (Software only)
- IRISCard Anywhere for Ms Dynamics (Scanner + software)

How to use Crm 2011 OData interface

http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc

http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet(guid'44b4727c-6419-e111-b506-00155d321b47')

http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet(guid'44b4727c-6419-e111-b506-00155d321b47')/FirstName

http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet(guid'44b4727c-6419-e111-b506-00155d321b47')/FirstName/$value
Result: Brain

// Related records
http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet(guid'44b4727c-6419-e111-b506-00155d321b47')/Contact_Emails

$orderby [asc | decs]

Paging
$skip
$top

Filtering
$filter

http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet?$orderby=FullName desc

http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet?$top=2&$skip=3

http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet?$filter=FullName eq 'Susan Burk (Sample)'

//Get detialed info from related entity
http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet?$expand=account_primary_contact

//ONly show some fields
http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/ContactSet?$select=FullName, AnnualIncome

//What entities are avaiable
//Options will not be available
http://dev1/KelvinPlayground/XRMServices/2011/OrganizationData.svc/$metadata

Some basic syntax



Another interesting thing: Microsoft data market where you can publish you crm data here via odata.

Use the Microsoft Dynamics CRM 4.0 (2007) Endpoint in Crm 2011

Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online provide a backward compatible endpoint that lets you continue to use code that was developed for Microsoft Dynamics CRM 4.0.

http:///MSCrmServices/2007/CrmService.asmx

Ref:
http://msdn.microsoft.com/en-us/library/gg334316.aspx

Connect to Crm 2011 WCF interface via code

Library needed

The project will need to use .Net4 profile.

Using needed

Get Service method
var creds = new ClientCredentials(); //Get your current login

Tuesday 17 January 2012

Crm 4 workflow update children records from a parent record

Reference: http://www.dynamicscrmtrickbag.com/2009/09/02/account-contact-update/

Synchronize Child and Parent Records – with Workflows
Sherry Hale, a long-time Trick Bag reader, recently emailed me the following question:

…can you make a workflow that when an account address is updated, the contacts that share that address are also updated? It seems simple, but I can’t seem to pull in contact entity information on an account related workflow, nor can I start a contact child workflow from an account workflow.

Unfortunately, I had to answer her that she was correct: it’s not as simple as it seems it would be! An automatic workflow written against the Account entity doesn’t know anything about child records (like contacts, as in this example). In this sense, workflows are similar to Dynamics CRM Advanced Find: child records know lots about parent records, but parents don’t know anything about children.

You certainly can do that with code, and as soon as I find a good example of that kind of code out there I’ll post an update with a link to it. [If you know of any good examples of that or have written code to that effect yourself, please let me know and I'll give you ample credit!]

Updating Child Records from a Parent … with an On Demand Workflow
But, notice I said above that you can’t do it with an automatic workflow on the parent entity (in this case, account, but this is a more general point and will work the same way for anywhere in CRM where you’ve got a 1:N relationship). If you can live with an “on demand” workflow written for the child entity, it’s actually quite straightforward.

Here’s how you do it:

Create a new workflow for Contact, call it something descriptive like “Update Contact from Parent Account”.
Uncheck the default “Record is created” checkbox in the “Options for Automatic…” section, and make it available to run on demand:


Pull down the Add Step menu and give it a single Update Record action, on Contact, as I show in the above figure, then click Set Properties, and use Dynamic Values in the Form Assistant to update the fields on the child record(remember, the workflow will be run against any selected contacts, in this example!) with any values you want from the parent record (you can see the “Parent Customer (Account)” entity selected in the “Related Entities” list below, and also reflected in the values I’m using to update the fields on the contact record:


Save and Close, publish, and you’re ready to go.

If the workflow is published as an On Demand workflow for Contact, you’ll see it on any contact grid, including the so-called “Contact Associated View” for accounts. In an example like the following figure shows, I’ve clicked the Run Workflow button on the toolbar (which you won’t see unless you’ve got one of the on demand workflows published for Contact), and I’m about ready to change 119 contact records with updated address information from their parent account record.

So, Sherry, it might not be automatic…but it’s a lot better than doing them one at a time.

One More Thing…
You might be thinking: big deal: I can do that with a bulk edit. (select all the contact records you want and select Edit from the More Actions menu, and any updates you make to the fields there will be applied to all selected records). While it’s true that sometimes this will work, there are two limitations (at least) to the bulk edit approach that will still work in the workflow approach:

Plenty of fields can’t be edited with a bulk edit (e.g., certain lookup fields, such as Parent Customer). Any field can be updated with the workflow approach I showed here.
Another advantage of the workflow update approach is that you can apply logic in a workflow. For example, suppose you only want to update certain of those child records with the parent record values, and other ones you didn’t. If there are criteria determining which ones get the update and which ones don’t, you can put that into a “Check Condition” in a workflow, whereas “bulk edit” really is a bulk edit, and gets applied to every record no matter what.
I wrote a book on Dynamics CRM workflows, by the way, and it contains tons of examples like this one and other useful workflows. You can purchase the book on Lulu.com or on Amazon, and if you do, you can also get a (free) subscription to the online version of the book, where you can download the workflows themselves, customizations, and related content.

Here’s a link you can visit to find out more about my book and purchase it:

Monday 16 January 2012

Generate code with crmsvcutil #crmsvcutil extension #OrganizationServiceContext #OrganizationServiceContext

Syntax
CrmSvcUtil.exe /url:http:////XRMServices/2011/Organization.svc
/out:.cs /username: /password: /domain:
/namespace: /serviceContextName:

An example for generating early bound entities with a service context
CrmSvcUtil.exe ^
/url:http://localhost:5555/Crm2011RTM/XRMServices/2011/Organization.svc ^
/out:Xrm.cs ^
/language:CS ^
/domain:playground ^
/username:user-defined-usrname ^
/password:user-defined-pwd ^
/namespace:Xrm ^
/servicecontextname:XrmServiceContext

::The following para will only work if you run this bat file in the sdk\bin folder due to required dlls.
::/codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration"

pause

An example for generating optionsets
CrmSvcUtil.exe ^
/codewriterfilter:"Microsoft.Crm.Sdk.Samples.FilteringService, GeneratePicklistEnums" ^
/codecustomization:"Microsoft.Crm.Sdk.Samples.CodeCustomizationService, GeneratePicklistEnums" ^
/namingservice:"Microsoft.Crm.Sdk.Samples.NamingService, GeneratePicklistEnums" ^
/url:http://servername/orgname/XRMServices/2011/Organization.svc ^
/out:OptionSets.cs

pause

* Copied from Crm 2011 sdk

To use the generated code you need using the following assemblies.
//For the on-premises or Internet-Facing Deployment (IFD) versions of Microsoft Dynamics CRM, //browse to the SDK\Bin\ folder.
Microsoft.Crm.Sdk.Proxy.dll

//For Microsoft Dynamics CRM for Outlook Online, browse to the SDK\Bin\Online\ folder.
Microsoft.Xrm.Sdk.dll

CodeGeneration extension VS no extension
Developer Extensions for Microsoft Dynamics CRM 2011 provides an extension to the CrmSvcUtil.exe command-line tool, called the Microsoft.Xrm.Client.CodeGeneration extension, which you can use to generate the data context and data transfer object classes for your Microsoft Dynamics CRM organization.

So what is the difference between use the extension or not?

As you can see from the screen dump below. When the codeCustomization extension is used, event related code is NOT generated therefore less code is generated. So use Microsoft.Xrm.Client.CodeGeneration to generate early bound crm entities are favorable. Just remember to run the bat file in the sdk\bin folder otherwise you may get error due to missing libraries.

Saturday 14 January 2012

How does the Manapouri power station works?

How does the Manapouri power station works?

http://patandpaulharvey.blogspot.com/2011/02/paradise-is-doubtful-sound-we-need-tag.html

iTune alternative. 3 Best Free Alternatives to iCopyBot.

iCopyBot
SharePod
CopyTrans Manager
iDump

http://www.3alternatives.com/free-alternatives-icopybot

How to use iPod as a USB disk.

Thursday 12 January 2012

KeyType:CrmWRPCTokenKey, Expired:True. The key specified to compute a hash value is expired, only active keys are valid.

Ever accessed Microsoft Dynamics CRM and got the error “The key specified to compute a hash value is expired, only active keys are valid.” The error logged in the trace is as follows:

MSCRM Error Report:
--------------------------------------------------------------------------------------------------------
Error: Exception of type 'System.Web.HttpUnhandledException' was thrown.

Error Number: 0x8004A106

Error Message: The key specified to compute a hash value is expired, only active keys are valid. Expired Key : CrmKey(Id:d0879dd3-7f9d-de11-a5c4-0003ff392bd3, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True, ValidOn:09/09/2009 20:32:01, ExpiresOn:10/12/2009 20:31:55, CreatedOn:09/09/2009 20:32:01, CreatedBy:NT AUTHORITY\NETWORK SERVICE.

Error Details: The key specified to compute a hash value is expired, only active keys are valid. Expired Key : CrmKey(Id:d0879dd3-7f9d-de11-a5c4-0003ff392bd3, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True, ValidOn:09/09/2009 20:32:01, ExpiresOn:10/12/2009 20:31:55, CreatedOn:09/09/2009 20:32:01, CreatedBy:NT AUTHORITY\NETWORK SERVICE.

Source File: Not available

Line Number: Not available

Request URL: http://localhost/Contoso/loader.aspx

Stack Trace Info: [CrmException: The key specified to compute a hash value is expired, only active keys are valid. Expired Key : CrmKey(Id:d0879dd3-7f9d-de11-a5c4-0003ff392bd3, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True, ValidOn:09/09/2009 20:32:01, ExpiresOn:10/12/2009 20:31:55, CreatedOn:09/09/2009 20:32:01, CreatedBy:NT AUTHORITY\NETWORK SERVICE.]
at Microsoft.Crm.CrmKeyService.ComputeHash(CrmKey key, Guid scaleGroupId, HashParameterBase[] parameters)
at Microsoft.Crm.CrmKeyService.ComputeHash(CrmKey key, HashParameterBase[] parameters)
at Microsoft.Crm.Application.Security.WRPCContext..ctor()
at Microsoft.Crm.Application.Controls.AppPage.ValidateWrpcContext()
at Microsoft.Crm.Application.Controls.AppPage.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

[HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.contoso_loader_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


Simply restart the asynchronous service and reset IIS. This should make it work!!!

NAV AX

Both NAV and AX are ERP systems.
NAV is for small and medium companies
AX is for large companies and it is good at dealing with products

Wednesday 11 January 2012

What needs to be done to Crm 4.0 Client when users' AD password changed.

What needs to be done to Crm 4.0 Client when users' AD password changed.

User configuration to allow Microsoft Dynamics CRM e-mail router access to mailbox
I. Open the Microsoft Dynamics CRM Web client.
II. Click Tools from the menu, and then click Options.
III. Click the E-mail tab.
IV. Mark Allow E-mail Router to use my credentials to send and receive e-mail on my
behalf.
V. Enter the domain and username in the User name open text box.
VI. Enter the domain password in the Password open text box.
VII. Click OK.

Note: If Microsoft CRM user’s passwords are set to expire periodically in Active Directory, you
must complete these steps every time the password changes.

Tuesday 10 January 2012

NZ IT companies, company

NV Interactive
Green Button

Dump the Entity Metadata Crm 2011

This sample shows how to use the MetadataService Web Service. It creates an XML file that provides a snapshot of attributes for a single entity using the Metadata APIs. You can then open this file with Microsoft Office Excel.

This sample code can be found in the following files in the SDK download:

Server\HowTo\CS\Metadata\HowToMetadata.cs
Server\HowTo\VB\Metadata\HowToMetadata.vb

Event Execution Pipeline, Message Processing Stages

Crm 2011
Event Execution Pipeline
IpluginExecutionContext.StageStage values are int. You can use optionsets help class file from 2011 sdk to do so more easily.

Crm 4
MessageProcessingStage
Compare with Crm2011 which has 5 stages.

Crm 4 Crm 2011 programming difference, Syntax difference

Type Mapping Between Versions CRM 2011 and CRM 4

http://osmosee.wordpress.com/2011/06/15/crm-2011-plugin-syntax-changes/

http://roman20007.wordpress.com/2010/09/13/5-syntax-changes-in-dynamics-crm-2011-plugins/

Type mapping between versions Crm 2011 and Crm 4

SDK changes I’ve noticed while porting this from CRM 4.0 to CRM 2011

• Enumeration classes like Microsoft.Crm.Sdk.MessageName, ParameterName are not available
• IPluginExecutionContext.Depth is equal to 2 when the plugin is executed in the Update message
• CrmMoney is now Money, was expecting decimal since most other CRM data types are native .net types
• To get all the columns use new ColumnSet(true) instead of new AllColumns()
Input/OutputParameters of IPluginExecutionContext is now typeof ParameterCollection instead of PropertyBag

Javascript difference:
http://community.dynamics.com/product/crm/crmtechnical/b/crminogic/archive/2011/02/19/difference-between-crm-4-0-and-crm2011-script-for-using-on-form-customization.aspx

Testing CRM 4 Plug-ins

Testing CRM Plug-ins

Also think about plugin tester vs NUnit.

Changing the custom entity prefix in Microsoft Dynamics CRM 2011

The prefix that will be used when new attributes are created can be changed by updating the default publisher. This can be done by following the steps below:

1. Navigate to Settings > Customizations > Publishers.
2. Select the default publisher from the list.
3. Modify the prefix, changing it from new to the desired custom prefix, and click Save and Close.
4. Publish customizations by going to Settings > Solutions, and clicking Publish All Customizations.

Additionally, if you would like to create some fields with the new_ prefix, and some fields with the custom prefix, you can create a custom solutions that utilizes the new prefix. You can also utilize multiple different custom prefixes by creating separate solutions that utilize these prefixes.

http://support.microsoft.com/kb/2500602