Freezing VisualStudio when using Silverlight + RIA

There is an issue that when you are using VisualStudio and you have a Silverlight project which references a RIA Service. The result is that your VisualStudio gets extremely slow in  especially in the  Silverlight UI Designer or at worst making VisualStudio to never come back again.

The fix is to add a registry key:

DisableLiveIntellisense [DWORD32] = 1

under:

  • 64bit: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\WCFRIAServices\v1.0
  • 32bit: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WCFRIAServices\v1.0

Veröffentlicht unter CRM 2011, General .Net, Microsoft Dynamics CRM | Verschlagwortet mit , | Hinterlasse einen Kommentar

Show/hide sections in javascript

There are basically two options to hide/show section via javascript:

SetSectionVisibilityByName: function (sectionName, isVisible) {
 /// <summary>Sets the visibility of a section which is identified by its name</summary>
 /// <param name="sectionName">Name of the section</param>
 /// <param name="isVisible">Specifies if visible or not</param>
 var tabs = Xrm.Page.ui.tabs.get();

 for (var i = 0; i < tabs.length; i++) {
 var tab = tabs[i];
 for (var y = 0; y < tab.sections.getLength(); y++) {
 if (tab.sections.get(y).getName() == sectionName) {
 tab.sections.get(y).setVisible(isVisible);
 }
 }
 }
 }
 SetSectionVisibilityByLabel: function (sectionLabel, isVisible) {
 /// <summary>Sets the visibility of a section which is identified by its label</summary>
 /// <param name="sectionLabel">Label of the section</param>
 /// <param name="isVisible">Specifies if visible or not</param>
 var tabs = Xrm.Page.ui.tabs.get();

 for (var i = 0; i < tabs.length; i++) {
 var tab = tabs[i];
 for (var y = 0; y < tab.sections.getLength(); y++) {
 if (tab.sections.get(y).getLabel() == sectionLabel) {
 tab.sections.get(y).setVisible(isVisible);
 }
 }
 }
 }
Veröffentlicht unter CRM 2011, Microsoft Dynamics CRM | Verschlagwortet mit | Hinterlasse einen Kommentar

Import multiple entites with CRM 2011

Objective: We have an excel sheet we would like to import into Microsoft CRM. Challenge: The excel sheet contains not only the data for one entity but for multiple ones. Instead of splitting this excel file into chunks we try to import it as whole and use CRM built-in functionality for multiple targets

  1. Of course the mapping stands first, so create one (not yet a technical one)
  2. Now we have identified that we need at least two entities, but CRM doesn’t let us create a data map for multiple entities through the UI (at least not yet). This means we have to create a more or less blank data map xml first. The SDK comes with some sample maps (sdk\resources\dataimportmaps) we can copy and modify. The “mapforsalesforcecontactaccount.xml” seems to be quite fine for this. Note: You don’t have to detail every field (attributemap) now, you can do this later in the ui.When you are ready it should look something like this:
  3. <Map Name="Name of this new map" Source="SourceName">
     <Description>A nice description to find it easier in a later point of time.</Description>
     <EntitiesPerFile>Multiple</EntitiesPerFile>
     <EntityMaps>
     <EntityMap TargetEntityName="new_inquiries" SourceEntityName="new_inquiries_source" Dedupe="Ignore" ProcessCode="Process">
     <AttributeMaps>
     <AttributeMap>
     <SourceAttributeName>last_name</SourceAttributeName>
     <TargetAttributeName>new_lastname</TargetAttributeName>
     <ProcessCode>Process</ProcessCode>
     </AttributeMap>
     </AttributeMaps>
     </EntityMap>
     <EntityMap TargetEntityName="lead" SourceEntityName="lead_source" Dedupe="Eliminate" ProcessCode="Process">
     <AttributeMaps>
     <AttributeMap>
     <SourceAttributeName>last_name</SourceAttributeName>
     <TargetAttributeName>lastname</TargetAttributeName>
     <ProcessCode>Process</ProcessCode>
     </AttributeMap>
     </AttributeMaps>
     </EntityMap>
     <EntityMap TargetEntityName="new_questionresponse" SourceEntityName="new_questionresponse_source" Dedupe="Ignore" ProcessCode="Process">
     <AttributeMaps>
     <AttributeMap>
     <SourceAttributeName>job</SourceAttributeName>
     <TargetAttributeName>new_textresponse</TargetAttributeName>
     <ProcessCode>Process</ProcessCode>
     </AttributeMap>
     </AttributeMaps>
     </EntityMap>
     <EntityMap TargetEntityName="new_questionresponse" SourceEntityName="new_questionresponse2_source" Dedupe="Ignore" ProcessCode="Process">
     <AttributeMaps>
     <AttributeMap>
     <SourceAttributeName>AnyOtherColumn in your source file</SourceAttributeName>
     <TargetAttributeName>new_textresponse</TargetAttributeName>
     <ProcessCode>Process</ProcessCode>
     </AttributeMap>
     </AttributeMaps>
     </EntityMap>
     </EntityMaps>
    </Map>

    Note: In this example even one entity is imported two times (with of course different data). One thing to keep in mind here you cannot specify the same sourceentityname more than once.

  4. Ok, now that we have the data map xml we’ll import it in CRM
  5. The data map should now be in our CRM. “Modifying” it is only possible while importing. So save the excel sheet that you have csv (unfortunately excel files are not supported). And start an import.
  6. Specify your file and its delimiters
  7. Select the newly created map
  8. Now in the next screen you can see the entities specified before in the xml. Clicking on one of them brings you the modify screen where you can do your mapping via the UI.
  9. Another cool thing is that for lookups you can specify the search field
  10. In the last screen (before importing) you can specify a name of a data map you would like to save the just modified one to save under
  11. And that’s it, we have a great data map we can work with

This guide is a starting point, although knowing that there are of course further cool things like “Transformation Mappings” which are not possible through the UI again. Transformation Mappings offer you for example the following (refer to the SDK for some more details):

  • Concatenation
  • Split
  • Substring
  • Replace
  • Assign Value
  • Add to Date
  • Adjust Current Date and Set Time
  • Advanced Add to Current Date
Veröffentlicht unter CRM 2011, Microsoft Dynamics CRM | Verschlagwortet mit , | Hinterlasse einen Kommentar

2011 Plugin and early bound types

When you want to write a plugin with early bound types (created via CrmSvcUtil), there is one special thing to remeber which is not mentioned (not that I have seen it) in the SDK.

In your plugins AssemblyInfo.cs add the following:

[assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]

 

If you won’t do this you might face the following exception:

Web Service Plug-in failed in SdkMessageProcessingStepId: {22E89A95-B030-E011-B63A-005056B04C18}; EntityName: new_myentity; Stage: 30; MessageName: Create; AssemblyName: Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception: Unhandled Exception: System.InvalidOperationException: Object of type 'new_myentity' can not be converted to type 'IBusinessEntity'

respectively one of those:

 Crm Exception: Message: An unexpected error occurred., ErrorCode: -2147220970, InnerException: System.InvalidOperationException: Object of type 'new_myentity' can not be converted to type 'IBusinessEntity'
System.InvalidOperationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #C1DC7AEC: System.InvalidOperationException: Object of type 'new_myentity' can not be converted to type 'IBusinessEntity'

Reference:

http://technet.microsoft.com/en-us/library/microsoft.xrm.sdk.client.proxytypesassemblyattribute.aspx
Veröffentlicht unter CRM 2011, Uncategorized | Verschlagwortet mit , | 1 Kommentar

Issue with 4.0 plugins in CRM 2011

If you have many plugins on your CRM 4.0 and you don’t want upgrade the code immediately when migrating to CRM 2011 – which should work due to the backward-compatibility – there can be several issues.

One of them is that the picklist values in the plugin context input paramters aren’t from the same type. Now they are OptionSetValues.

So the following code is backward-compatible:

DynamicEntity incidentAttributes = yourGetEntityCode();
Picklist priorityCode = (Picklist)incidentAttributes["prioritycode"];
if (!priorityCode.IsNull)
{
 int priorityCodeValue = priorityCode.Value;
 string priorityCodeName = priorityCode.name;
}

 

But this one is not:

int statusCode = (int)context.InputParameters.Properties["Status"];

Because context.InputParameters.Properties["Status"] is now of type “OptionSetValue”.

Veröffentlicht unter CRM 2011, CRM 4.0 -> 2011, Microsoft Dynamics CRM | Verschlagwortet mit , , | Hinterlasse einen Kommentar

Debugging using Windgb

Debugging using Windgb, to get more details:

  1. I installed Windows Debugger tools
  2. I ran “”C:\Program Files\Debugging Tools for Windows (x64)\windbg.exe””
  3. Opened the CrmAsyncService.exe there respectively attached to its process
  4. Entered “sxe e0434352” so that it will stop at this exception
  5. As soon as it stoped I entered “!analyze -v”

 

Veröffentlicht unter General .Net | Verschlagwortet mit | Hinterlasse einen Kommentar

Filtered Lookup limit to custom view

I already wrote an articel about filtered views in CRM 2011 (see ).

However probably in the most cases you would also like to restrict the lookup view to only your custom one.

This is achievable by making your custom view the default view and then restrict the lookup to the default view.

  1. Before adding the custom view set the disableviewpicker attribute to 0. (i.e. $(“#new_YourAttributeId”).attr(“disableViewPicker”, “0″);)
  2. Add your custom view.
  3. After adding the custom view set the disableviewpicker attribute to 1. (i.e. $(“#new_YourAttributeId”).attr(“disableViewPicker”, “1″);)
Veröffentlicht unter CRM 2011, Microsoft Dynamics CRM | Verschlagwortet mit , | Hinterlasse einen Kommentar

Workflow timeout until issue with custom activity

I’ve had an issue with a custom workflow, after a migration from CRM 4.0 to CRM 2011

It looks like within a “Timeout until” condition is bug when waiting until a Date coming from a Custom Activity (references to Entity-Attributes worked). You can configure the “Timeout until” with the Custom Activity Date, but as soon as you published the workflow it was set back to “Process-Execution Time” which does not work as this date is in the past.

The <<workaround>> was to add 1 Minute to the output of the custom activity.

Original (“Wait until address reminder date is reached” -> Timeout until Calculate the DateTime 13 weeks in advance:Calculated Date then)

After Migration (“Wait until address reminder date is reached” -> Timeout until Process-Execution Time then)

Fix (Change “Wait until address reminder date is reached” -> Timeout until 1 Minute After Calculate the DateTime 13 weeks in advance:Calculated Date then)

Veröffentlicht unter CRM 2011, Microsoft Dynamics CRM | Verschlagwortet mit , | Hinterlasse einen Kommentar

Find stored procedures containing

Have you ever thought “Did I query table XYZ in one of my stored procedures?”, here is a way to get an answer:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
 FROM INFORMATION_SCHEMA.ROUTINES
 WHERE ROUTINE_DEFINITION LIKE '%foobar%'
 AND ROUTINE_TYPE='PROCEDURE'
Veröffentlicht unter SQL | Hinterlasse einen Kommentar

Identify invalid stored procedures

In a often changing system, it is sometimes required to see if all existing stored procedures are still working. To achieve this quick and for all procedures use the following sql:

DECLARE abc CURSOR FOR
 SELECT ROUTINE_NAME
 FROM INFORMATION_SCHEMA.routines
 WHERE ROUTINE_TYPE = 'PROCEDURE'
OPEN abc

DECLARE @ViewName varchar(128)

-- Build select string
DECLARE @SQLString nvarchar(2048)

FETCH NEXT FROM abc
INTO @ViewName
WHILE @@FETCH_STATUS = 0
BEGIN
 SET @SQLString = 'EXECUTE sp_refreshsqlmodule '+@ViewName
 PRINT '---------------------------------'
 PRINT '-- Checking ' + @ViewName + '...'
 BEGIN TRY
 BEGIN TRANSACTION;
 EXECUTE sp_ExecuteSQL @SQLString
 ROLLBACK TRANSACTION;
 END TRY
 BEGIN CATCH

 DECLARE @ErrorMessage NVARCHAR(4000);
 DECLARE @ErrorSeverity INT;
 DECLARE @ErrorState INT;

 SELECT
 @ErrorMessage = ERROR_MESSAGE(),
 @ErrorSeverity = ERROR_SEVERITY(),
 @ErrorState = ERROR_STATE();

 RAISERROR (@ErrorMessage, -- Message text.
 @ErrorSeverity, -- Severity.
 @ErrorState -- State.
 );

 ROLLBACK TRANSACTION;
 END CATCH
 FETCH NEXT FROM abc
 INTO @ViewName
END
CLOSE abc
DEALLOCATE abc
Veröffentlicht unter SQL | Hinterlasse einen Kommentar