Entity Display Areas and the CRM SiteMap

On November 17, 2009, in Customization, Dynamics CRM, by Mitch Milam

If you’ve ever created a custom Entity within CRM you’ve had to make a decision about where this new Entity should be shown using the following checkboxes found at the bottom of the Information screen:

image

I was replying to a question on one of the CRM Forums where the poster wanted to know where this information was stored.  This turned out to be an excellent question, the answer to which is not readily apparent.

It turns out that there are not actually fields in the database that contain this information.  When you make a change to the display areas and save the Entity, it actually rewrites the XML that is used to display the SiteMap.

That means you can’t just turn these settings on or off programmatically.

You can, however, read this information by using the CRM SDK to query the Organization Entity and retrieving the SiteMapXml property.

Just look for instances where the Entity in question is referenced.

While the SDK clearly states that this field can be written to, I would strongly advise against it unless you have an excellent backup and really know what you’re doing.

 

Interesting Support Article Find: 947096

On November 16, 2009, in Customization, Dynamics CRM, by Mitch Milam

When trying to export and/or publish, I ran into this issue this week:

Details: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Stack trace:
[NullReferenceException: Object reference not set to an instance of an object.] at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoaderAllLanguages.LoadMetadataLabel(Int32 entityType, String attributeName, ExecutionContext context) at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoader.LoadCellLabel(Guid cellObjectId, String cellObjectColumnName, Int32 objectType, String attributeName, ExecutionContext context) at …..

After doing some digging, I found this article:

Error message when you export or delete entities in Microsoft Dynamics CRM 4.0: "An unhandled exception occurred during the execution of the current web request"

 

For some reason, we have an issue where something has been deleted from CRM but a reference it still exists somewhere: on the form, a view, etc.  Maybe you deleted the item on purpose or maybe you are moving customizations between servers and you didn’t get all of the referenced entities when you exported.

It’s a little hard to track down sometimes, but you can see things like this on your form:

image

Or you’ll see the yellow warning symbol on a view column within the View Designer.

Good luck.

 

At one of my current customers we had a rather interesting business requirement that I thought I’d share the solution for.

We have an automated system that imports faxes into CRM from a centralized fax gateway product.  We naturally create a Fax Entity record and attach the fax file ( which is a PDF in this case ) to the record.

So far, this is normal business processing.  Here comes the interesting part.

Due to a secondary business requirement, we don’t want users entering Notes on Faxes.  This presents a problem because Attachments are shown as Notes.  Since some issues can’t easily be controlled training, I started looking for a way of restricting the user from creating notes.

Note: I should also mention that all of our Faxes are Incoming, not Outgoing, and we only create inbound faxes programmatically.

Modifying the user’s security role would have worked, mostly, it may have caused problems in the future.  So I decided to invest in a little JavaScript.  This goes in the form OnLoad event of the Fax Entity:

//
// Hide the add note link to prevent users from adding a note manually
//
crmForm.all.tab2Tab.onclick = function() 
{ 
   document.all["notescontrol"].contentWindow.document.all.newNoteButton.style.display = 'none'; 
}
 

Ok, this is mostly unsupported, but not in a major way.   What we are doing is appending a new Click event on the Notes tab ( which is tab #2, if counting from 0 ).

When a user clicks on the Notes tab, this small bit of JavaScript is executed and the Create new note hyperlink is hidden.

 

The Microsoft Engineering for the Enterprise team has released another white paper this week:

Security and Authentication in Microsoft Dynamics CRM: Field-level Security in Microsoft Dynamics CRM: Options and Constraints

Brief Description

While Microsoft Dynamics CRM does not provide for true field-level security, there are a number of options available for using supported custom logic to control of access to data at a more granular level than provided out of the box. This document discusses some of the key options and constraints available for implementing this type of solution.

 

Overview

This white paper, Field-level Security in Microsoft Dynamics CRM: Options and Constraints, provides selected aspects of the conceptual application of the security model in Microsoft Dynamics CRM. While Microsoft Dynamics CRM does not provide for true field-level security, there are a number of options available for using supported custom logic to control of access to data at a more granular level than provided out of the box. This document discusses some of the key options and constraints available for implementing this type of solution.

 

Revised CRM SDK 4.0.10

On November 10, 2009, in Customization, Development, Dynamics CRM, by Mitch Milam

The initial release of Microsoft Dynamics CRM SDK 4.0.10 contained an incorrect assembly in the SDK\Bin folder. This has been corrected.

Please visit the download page to refresh your copy:

http://www.microsoft.com/downloads/details.aspx?FamilyID=82E632A7-FAF9-41E0-8EC1-A2662AAE9DFB&displaylang=en

The only change to this download package is the contents of the SDK\Bin folder.  The readme has been updated to indicate this change.

Look for this notice:

“November 10, 2009 – Updated the assemblies in the Bin folder. Use these updated assemblies instead of the ones in the previous release of SDK 4.0.10.â€?

This may take a few hours to propagate across all of the MSDN servers but should be available by Wednesday.

 

CRM SDK 4.0.10 Released

On November 7, 2009, in Customization, Dynamics CRM, by Mitch Milam

It looks like the SDK team released a new version this week  Download it here.

Here is what is in this update:

New and updated topics

Description of changes

SDK\SDKReadme.htm

Updated the SDK readme.

SDK\WSDL

Removed the SDK\WSDL folder containing the discovery service WSDL. The WSDL is available through Microsoft Dynamics CRM Online.

SDK\Tools\PluginRegistration

Updated the sample code with bug fixes. The version of the tool is unchanged.

SDK\Server\FullSample\customworkflowactivity

Updated the project and readme to add several new custom workflow activities that you can call from a workflow. For a description of each custom workflow activity, see List of Samples in the SDK Download.

Server\HowTo\CS\
BulkOperation\CreateQuickCampaign.cs

Server\HowTo\VB\
BulkOperation\CreateQuickCampaign.vb

Removed these samples.

SDK\Walkthroughs\Authentication\VB\Passport\

PassportAuthentication_Metadata.vb

Added a Visual Basic .NET version of the authentication sample for the metadata service.

appointment.actualdurationminutes

serviceappointment.actualdurationminutes

Added remarks that explain that actual duration minutes is set when the state of the activity is changed to Completed. This applies to all activities.

BulkOperationEntities

Bulk Operation Entity Capabilities

Clarified that the bulk operation entity is only used for campaign and quick campaign and it is not used for bulk delete, bulk e-mail, or bulk import operations.

Choosing Between the WSDL and Assemblies

Added a new page that describes when you should use the WSDL versus the assemblies for your development.

CorrelationToken.CorrelationId

Added additional documentation for this property.

Create a Campaign

Added a How-to topic that shows how to create a campaign.

CrmDiscoveryService Messages

Added a page that lists the messages supported by the CrmDiscoveryService Web service.

CrmHelpers Classes

SDK\Server\FullSample\UsingHelpers\CS\VB

SDK\Server\Helpers\CS|VB\CrmHelpers

Updated the helper code programming reference for Microsoft Dynamics CRM 4.0 Update Rollup 7 and Microsoft Dynamics CRM Online.

Customizations using the Microsoft Dynamics CRM SDK

Clarified information regarding the fact that using scripts to hide form elements is not supported and not upgradable.

Import/Export (Customization File) Schema

SiteMap Schema

SDK\Server\Schemas

Updated the customization schema for new features in Microsoft Dynamics CRM Online.

importfile.datadelimitercode Property

Clarified information about how to use this property.

importfile.filetypecode Property

importmap.mapcustomizations Property

ImportFileType Class (CrmHelpers)

Documented a new filetype property that specifies the type of the uploaded source file that is used for import and data migration. This property is available in Microsoft Dynamics CRM Online only The new mapcustomizations property is for internal use only.

Documented a new enumeration that contains the values for the importfile.filetype property.

Microsoft Dynamics CRM Online Authentication

SDK\Server\Reference\cs\discoveryservice\*.cs

SDK\Server\Reference\vb\discoveryservice\*.vb

Updated the source code samples in the documentation and in the SDK download to obtain the organization-specific CrmService Web service URL from the discovery service instead of using a hardcoded string.

Updated the RetrieveCrmTicket, and RetrieveOrganizations samples. Added a sample for RetrieveOrganizations for Microsoft Dynamics CRM Online.

organization.getstartedpanecontentenabled Property

organization.sampledataimportid Property

SubArea Element

usersettings.getstartedpanecontentenabled

usersettings.homepagelayout

Added new properties to control the Getting Started pane content and the sample data for an organization, and the getting started pane and home page layout for a user.

Added new attributes to the SubArea element of the SiteMap to control the Getting Started pane.

The Getting Started Pane is available in Microsoft Dynamics CRM Online only.

RetrieveMembersBulkOperationRequest.Query

Added a new query property to this request, which can be used to limit the data returned when working with very large data sets. This property is available in Microsoft Dynamics CRM 4.0 Update Rollup 7.

RetrieveOrganization

Added a new discovery service message that retrieves an organization. This message is available in Microsoft Dynamics CRM Online only.

Support for .NET Framework Versions

Updated supported .NET versions to include .NET 3.5, which is needed for visualizations (charts).

Unsupported Customizations

Updated the list of supported DLLs.

User Interface Style Guide

SDK\StyleSheet\sample.htm

SDK\StyleSheet\template.css

SDK\StyleSheet\images\form_back.gif

SDK\StyleSheet\images\form_toolbar_back.gif

SDK\StyleSheet\images\statusbar_back.gif

Added HTML, CSS, and image files that provide a starting point for creating Web pages that look similar to Microsoft Dynamics CRM. Updated the User Interface Style Guide to introduce them.

Using Filters in a Report

Updated information about enabling data pre-filtering on reports.

Using Pre-generated XmlSerializers to Increase Performance

About the Assemblies

SDK\Bin\64bit\Online\
Microsoft.Crm.SdkTypeProxy.XmlSerializers.dll

SDK\Bin\64bit\
Microsoft.Crm.SdkTypeProxy.XmlSerializers.dll

SDK\Bin\Online\
Microsoft.Crm.SdkTypeProxy.XmlSerializers.dll

SDK\Bin\
Microsoft.Crm.SdkTypeProxy.XmlSerializers.dll

Added information about how to improve performance and minimize memory usage when creating XmlSerializer objects or instantiating Web service proxy classes.

Added the Microsoft.Crm.SdkTypeProxy.XmlSerializers.dll assembly to the list of supported assemblies.

Added the Microsoft.Crm.SdkTypeProxy.XmlSerializers.dll assemblies.

Using the ColumnSet Class

Added a warning about the possible adverse effects of using AllColumns in a query expression.

Using the Paging Cookie

Server\HowTo\CS\Paging\
FetchPagingWithCookie.cs

Server\HowTo\VB\Paging\
QueryExpressionPagingWithCookie.vb

Server\HowTo\CS\Paging\
FetchPagingWithCookie.cs

Server\HowTo\VB\Paging\
QueryExpressionPagingWithCookie.vb

Added sample code that shows how to use the paging cookie from using Fetch and using Query Expression.

Visualizations (Charts)

Visualization (Chart) Sample Code

Visualization (Chart) Data Description Schema

savedqueryvisualization

Server\FullSample\
CreateVisualization\CS|VB

SDK\Server\Schemas

Added documentation for the new Visualizations (Charts) feature, available for the R4 release of Microsoft Dynamics CRM Online only.

Walkthrough: Client to Server Authentication with CRM Online

Walkthrough: Server to Server Authentication with CRM Online

SDK\Walkthroughs\authentication\cs|vb

SDK\Server\FullSample\
ServerToServerImpersonate

Updated the source code samples in these walkthroughs to obtain the organization-specific CrmService Web service URL from the discovery service instead of using a hardcoded string.

Walkthrough: Client to Server Authentication with CRM Online

SDK\Walkthroughs\authentication\cs|vb

Updated the procedure to download the discovery service WSDL from Microsoft Dynamics CRM Online.

Walkthrough: Creating and Registering a Custom Workflow Activity

Added a walkthrough to demonstrate the steps needed to create a custom workflow activity, register it, and use it from the workflow designer.

 

Trouble Ticket of the Day

On November 6, 2009, in Misc, by Mitch Milam

From a user at one of my customers:

CRM not cooperating.

Hmm, not exactly sure how to respond to that.

 

I am sure that there is another blog that has posted code like this before, but I was cleaning up a project this morning, saw these two methods, and decided to just post them here so I could find them later. :)

These are in C#.  For more information on how they work, please review the CRM SDK.

 

private void CloseOpportunity(Guid opportunityId, int statusCode, string description)
{
    opportunityclose oppclose = new opportunityclose();
    oppclose.opportunityid = new Lookup();
    oppclose.opportunityid.type = EntityName.opportunity.ToString();
    oppclose.opportunityid.Value = opportunityId;
    oppclose.description = description;
    oppclose.actualend = new CrmDateTime(DateTime.Now.ToString());

    WinOpportunityRequest woReq = new WinOpportunityRequest();
    woReq.OpportunityClose = oppclose;
    woReq.Status = 3;   // Won;

    crmService.Execute(woReq);
}

private void CancelOpportunity(Guid opportunityId, int statusCode, string description)
{
    opportunityclose oppclose = new opportunityclose();
    oppclose.opportunityid = new Lookup();
    oppclose.opportunityid.type = EntityName.opportunity.ToString();
    oppclose.opportunityid.Value = opportunityId;
    oppclose.description = description;
    oppclose.actualend = new CrmDateTime(DateTime.Now.ToString());

    LoseOpportunityRequest woReq = new LoseOpportunityRequest();
    woReq.OpportunityClose = oppclose;
    woReq.Status = statusCode;

    crmService.Execute(woReq);
}

 

CRM Customization Filename Length

On November 4, 2009, in Customization, Dynamics CRM, by Mitch Milam

Judging from the error message below, it would appear that there is a limit to the length of a filename you use when importing CRM customizations:

image

Something to keep in mind.

 

Automating Task Notification

On November 2, 2009, in Customization, Dynamics CRM, Workflow, by Mitch Milam

If you have ever assigned a task to someone and wondered when or if they completed it, this workflow process may help.

This workflow is based the Task activity, but you can perform the same process on other activities as well.

The workflow will execute when the record’s status changes.

Here is a quick picture of how it is configured.

image

Our first check is to see if the Task was closed with either a Completed or Canceled status.

If so, then we check the owner.  Is it the same person who created it?  If not, then we will send an email to the creator of the Task, using the following email:

image

When published, the workflow will generate an email that looks like this:

image