Archiv der Kategorie: Dynamics CRM

Using HttpUtility.UrlEncode in a plugin leads to a SecurityException

In a recent project I had to develop a plugin which is executed in the plugin sandbox. The sandbox restricts the rights plugins to a ’safe‘ amount. See for a description. According to the SDK, web request are allowed.

Part of my task was to send a request to a web service which expects data URL-encoded. Normally you would use following class (part of System.Web)

HttpUtility.UrlEncode("some data here");

I was surprised that this leads to a SecurityException if used in a sand-boxed plugin. The sandbox does not allow the use of this class.

Instead of rewriting the method (I hate reinventing the wheel…) I’ve searched for a replacement, and found

Uri.EscapeDataString("some data here");

which is usable in sand-boxed plugins. For my task the result was the same as with UrlEncode, however I am not sure I they are different in their results.

Do I need that SPN?

One important thing that is often forgotten during/after the installation of Dynamics CRM is to properly set the SPNs for your service accounts (if necessary 😉 ).
Here are three links which I often take as reference when we plan new deployments:

Howto: extend the maximum value for duration attributes

If you have ever tried to enter a duration of more than 10 days for a service activity you would have seen that the system won’t accept this value.

The duration of the appointment is invalid

If you need to change the maximum value you are able to do this directly in the database (which is officially supported – quote of a support ticket below).

  • There is no way to modify the limit for service duration via UI. We will read this value from a SQL table and there we can change the default setting.

    Database: [Organization]_MSCRM

    Table: OrganizationBase

    Field: MaxAppointmentDurationDays

    Default value: 10

  • If you overwrite this value with the needed one (for example 20) and after that perform an IISReset, the known error message („The duration of the appointment is invalid“) will no longer occur.

    This change is the recommended solution from Microsoft CRM Support and will be supported.

  • Background: This field does come originally from CRM 3.0, where customer already provided feedback that the maximum duration of 10 days does not meet their need. The solution for CRM 3.0 was a solution implementation via registry key: Navigate to the following registry hive: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM. Create a registry key of type DWORD and name it „SchedulingEngine.MaxAppointmentDurationDays“. Provide a reasonable digit greater than 10 representing the number of days the service activity would be kept open and insure that the value is set to Decimal and not Hexadecimal. Now you can schedule an appointment with a duration value of more than 10 days.
  • For CRM 4.0 you will need a manual change of the according OrganisationBase entry. Exception: If you upgrade your CRM installation from CRM 3.0 to CRM4.0, the value will be automatically carried over

Another possibility to adjust this setting is to change the organization.maxappointmentdurationdays Property via the sdk.

MissingMethodException at E-Mail-Router installation

This week I’ve installed the E-Mail-Router for a customer. During the setup an error came up

Action Microsoft.Crm.Setup.Exchange.GenerateEncryptionKeyAction failed.

Method not found: ‚Boolean Microsoft.Crm.ApplicationConfig.IsFederalInformationProcessingCompliant()‘.

The cause of this error was a pending restart which was requested by Windows Update. I have no clue if a specific update was the cause of the problem, or the system state itself.
However, after rebooting the machine, the error went away and the setup was successful.

So keep in mind, if the pre-checks warns you about a pending reboot, it is sometimes better not to ignore this hint 😉