Category: 2011

Queue Item Work On vs. Case Assign


  1. When we say Assign on a particular CRM Case then it changes the Owner of the case.



    But when we say “Work on” on a “Queue Item” then it updates “Worked By” field in “Queue Item Details” rather than changing the owner of the case.



    Many a times mistake is made in considering these functionalities as same and can lead to design flaws in Application.


  2. When a case is assigned “Assign” message is triggered for a plugin but when we “Work On” from “Queue”, Update message is triggered on “Queue Item”.


  3. Out of the box CRM 2011 doesn’t provide any functionality to keep these both in sync so custom code (plugin) will be required to keep both these values in sync.


  4. If you want to move a case to user queue when it is assigned to user you can use out of the box feature of case entity (but it is not same as keeping work on and assigned to in sync as it is limited till a user queue only)


Record in Multiple Queue Error in CRM 2011

While looking at Queue Item Details we were getting Error


“This record is in multiple queues. Go to specific queue to view details.”


On doing the repro steps it was realized that this is the message that we get when a case is reactivated after being closed.

This is because a queue item related to same case is already there in CRM in deactivated state.


To resolve this we wrote a plugin to reactivate the queue item and assign it to a next level queue based on business logic.

Source Code to Reactivate Queue Item (Entity) in CRM 2011

[sourcecode language=”csharp”]

var entityMoniker = localContext.PluginExecutionContext.InputParameters[“EntityMoniker”] as EntityReference;

var incidentid = entityMoniker.Id;

QueryExpression query = new QueryExpression();

query.EntityName = “queueitem”;

query.ColumnSet = new ColumnSet();

query.ColumnSet.Columns.AddRange(new string[] { “statecode”, “statuscode”, “queueitemid” });

query.Criteria = new FilterExpression();

query.Criteria.AddCondition(“objectid”, ConditionOperator.Equal, incidentId);

query.Criteria.AddCondition(“statecode”, ConditionOperator.Equal, 1);

EntityCollection results = serviceContext.RetrieveMultiple(query);

if (results != null && results.Entities != null && results.Entities.Count > 0)


SetStateRequest setQueueItemState = new SetStateRequest();

setQueueItemState.EntityMoniker = new EntityReference(“queueitem”, results.Entities[0].Id);

setQueueItemState.State = new OptionSetValue(0);

setQueueItemState.Status = new OptionSetValue(1);




Repro Screenshots:

  1. Create case:


  1. Add it to queue


  2. Work On


  3. Resolve it

  4. Reactivate it:

  5. Add to queue Again

  6. Try to open queue item details.



    Error Message:

Import Solution Issue in UR 12

Recently we tried to import solution on CRM which was recently updated from UR 6 to UR 12.

Solution we had was taken from same server from a different org (after upgrade) and was getting stuck at the import step with no activity (at all) in progress bar.

Following Exception was there in CRM Trace log viewer

at CrmException..ctor(Int32 errorCode, Object[] arguments) ilOffset = 0x36

at SolutionImportProcessPage.ProcessRequestData() ilOffset = 0x4A

at SolutionImportProcessPage.ProcessAction(String action) ilOffset = 0x92

at AppUIPage.OnPreRender(EventArgs e) ilOffset = 0xD

at Control.PreRenderRecursiveInternal() ilOffset = 0x54

at Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) ilOffset = 0x6D3

at Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) ilOffset = 0x3C

at Page.ProcessRequest() ilOffset = 0x14

at Page.ProcessRequest(HttpContext context) ilOffset = 0x31

at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() ilOffset = 0x18D

at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) ilOffset = 0x15

at ApplicationStepManager.ResumeSteps(Exception error) ilOffset = 0x10A

at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) ilOffset = 0x5C

at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) ilOffset = 0x16A

at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType) ilOffset = 0x4B

>Crm Exception: Message: An error occurred while importing a Solution., ErrorCode: -2147188685

To resolve this following post from Microsoft discussion forum helped

  1. Stop Async Service in services.msc
  • Run “services.msc”
  • Stop Async Service


2.  Take Microsoft.crm.sdk.proxy.dll from latest sdk

3.  Open Visual studio command line tools (in administrator privileges)


gacutil /i c:sdkbinMicrosoft.crm.sdk.proxy.dll


4.  IIS reset, restart CRM Async Service in services.msc

Try importing the solution


PS: If you are in a farm deployment then Install Microsoft,crm.sdk.proxy.dll in the server running CRM Async Service.

Before installing dll, stop the async service, install dll in gac and restart async service.


Dependency Records Error while importing Managed Solution

Error While Importing Managed Solution in CRM 2011:


Found 2 dependency records where unmanaged component is the parent of a managed component. First record (dependentcomponentobjectid = a7f9b236-452f-e211-aa3e-00155dc87c5a, type = AttributeMap, requiredcomponentobjectid = 8d4b6bc4-b4ed-e111-aba2-00155d018410, type= EntityMap, solution = b18c1343-ea7f-4eaa-abf7-31d81ade819c).


The cause of above error it that there is custom Mapping between Managed Entity and Unmanaged Entity pre-existing in the system and system is not able to replace those mappings.

Resolution (More of a workaround):

  1. Unzip the managed solution.
  2. Edit customizations.xml, replace … tag inside with , Save.

    (Here you just removed all mappings)

  3. Zip the solution, Import it.
  4. Import Original Managed Solution solution. à Pay attention here you imported solution twice. Once without mappings, Once with that.

Thanks to Kjell L for the solution.

“AuditPFN” Issue while restoring MS Dynamics CRM 2011 Database Backup

While restoring CRM 2011 Database if you face following Error:


An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Database ‘DatabaseName’ cannot be started in this edition of SQL Server because it contains a partition function ‘AuditPFN’. Only Enterprise edition of SQL Server supports partitioning. Database ‘DatabaseName” cannot be started because some of the database functionality is not available in the current edition of SQL Server. (Microsoft SQL Server, Error: 905).


The cause of above exception is the SQL Server you are importing from is SQL Server Enterprise Edition but SQL Server you are importing to is not same.

While creating Org in SQL Server Enterprise Edition a partition is created in the DB for auditing purpose. The AuditBase table uses partition which is available only in Enterprise Edition.


  1. Backup (1) SQL DB from where you want to take backup to restore 😉 (Used in case you messup anything in SQL)
  2. Run given script against that DB.

[sourcecode language=”sql”]

IF EXISTS (SELECT name FROM sys.partition_schemes WHERE name=’AuditPScheme’) BEGIN SELECT   CASE WHEN ind.type != 1    THEN     ‘DROP INDEX [dbo].[AuditBase].’ + QUOTENAME( + ‘ ‘    ELSE ‘ ‘   END +   ‘CREATE ‘ + CASE is_unique WHEN 1 THEN ‘UNIQUE ‘ ELSE ” END  +   ind.type_desc + ‘ INDEX ‘ + QUOTENAME(  COLLATE SQL_Latin1_General_CP1_CI_AS )  + ‘ ON [dbo].’ +  QUOTENAME(OBJECT_NAME(object_id)) + ‘ (‘ +      REVERSE(SUBSTRING(REVERSE((    SELECT name + CASE WHEN sc.is_descending_key = 1 THEN ‘ DESC’ ELSE ‘ ASC’ END + ‘,’    FROM     sys.index_columns sc     JOIN sys.columns c ON sc.object_id = c.object_id AND sc.column_id = c.column_id    WHERE     OBJECT_NAME(sc.object_id) = ‘AuditBase’ AND     sc.object_id = ind.object_id AND     sc.index_id = ind.index_id    ORDER BY index_column_id ASC    FOR XML PATH(”)         )), 2, 8000)) + ‘)’ +   CASE WHEN ind.type = 1    THEN     ‘ WITH (DROP_EXISTING = ON) ON [PRIMARY]’    ELSE     ‘ ‘   END  as Script INTO #indexesScript FROM sys.indexes ind JOIN sys.partition_schemes ps on ind.data_space_id=ps.data_space_id WHERE   OBJECT_NAME(object_id) = ‘AuditBase’   AND = ‘AuditPScheme’   AND is_unique_constraint = 0 SELECT * FROM #indexesScript   DECLARE @recreateScript nvarchar(max) DECLARE indScript CURSOR FOR SELECT Script FROM #indexesScript OPEN indScript FETCH NEXT FROM indScript INTO @recreateScript   WHILE @@FETCH_STATUS = 0   BEGIN     BEGIN TRANSACTION t1   Execute sp_executesql @recreateScript     IF @@ERROR > 0   BEGIN    ROLLBACK TRAN t1    declare @message varchar(max)    set @message = ‘Audit history recreate index failed. SQL: ‘ + @recreateScript       RAISERROR (@message, 10,1)   END   ELSE   BEGIN    COMMIT TRAN   END   FETCH NEXT FROM indScript INTO @recreateScript   END   DROP PARTITION SCHEME AuditPScheme DROP PARTITION FUNCTION AuditPFN   CLOSE indScript   DEALLOCATE indScript DROP TABLE #indexesScript END


3. Backup (2) DB again (Used for import on you non Enterprise Edition SQL Server)

4. Restore the above backup [Backup (2)].

Not My solution J Just found Online here.

Microsoft Dynamics CRM 2011 Developer Tool Kit.

Being a CRM Developer for Microsoft Dynamics CRM 2011 its always frustrating to make customizations and then publish the content or to export the solution unzip it and then zip it and Export it back to the CRM. Microsoft has again taken a step to make your life easier (as it always does) and has released a Visual Studio plugin for you. In the latest CRM SDK you can find Developertoolkit in tools folder and this can be used to create plugins, silverlight webresources, make changes in solution and Deploy it to the CRM server all using CRM explorer in your Visual Studio.

You can download latest CRM SDK from