The [x]([GUID]) component cannot be deleted because it is referenced by [y] other components. For a list of referenced components, use the RetrieveDependenciesForDeleteRequest.


When you get this message, then you can find the dependencies through a webservice call. If you don't have a programming environment available, then it can be hard to find out what causes the delete to be cancelled. For instance, when the component isn't easily accessible through the CRM UI. For on-premise solutions where you can access the database, it's pretty easy to find out what is the dependent component. Just run the stored procedure:

exec p_RetrieveDependenciesForDelete '[GUID]' [ComponentType]

for example:

exec p_RetrieveDependenciesForDelete '37BB549F-8D9A-E511-80D3-005056BB2FDF', 52

The Guid is mentioned in the error message, just copy this into the query. The Component type can be found here:

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/solutioncomponent?view=dynamics-ce-odata-9

Cheers!



Insight in AsyncOperationBase needed?

If you're asyncoperationbase has grown beyond 1.000.000 records, then you most likely want to clean this up for performance reasons.

You can just jump to the Microsoft KB article and run some scripts to clean this up, but you might also want to do some more research upfront to avoid getting into this situation again. Our friends at PowerObjects have written a nice article about this. Another approach would be to run the script below. This shows the most common events (more than 10.000 entries) that are stored in the table. The last column indicates if these records will be removed using the Microsoft KB article.

If you want to filter events based on the amount of occurrences, then you can simply change the threshold.

Enjoy!


declare @threshold as int

set @threshold = 10000

SELECT

Name,

DATEPART(YEAR,CreatedOn) AS [Year],

DATEPART(MONTH,CreatedOn) AS [Month],



case operationtype

when 1 then  'System Event'

when 2 then  'Bulk Email'

when 3 then  'Import File Parse'

when 4 then  'Transform Parse Data'

when 5 then  'Import'

when 6 then  'Activity Propagation'

when 7 then  'Duplicate Detection Rule Publish'

when 8 then  'Bulk Duplicate Detection'

when 9 then  'SQM Data Collection'

when 10 then  'Workflow'

when 11 then  'Quick Campaign'

when 12 then  'Matchcode Update'

when 13 then  'Bulk Delete'

when 14 then  'Deletion Service'

when 15 then  'Index Management'

when 16 then  'Collect Organization Statistics'

when 17 then  'Import Subprocess'

when 18 then  'Calculate Organization Storage Size'

when 19 then  'Collect Organization Database Statistics'

when 20 then  'Collection Organization Size Statistics'

when 21 then  'Database Tuning'

when 22 then  'Calculate Organization Maximum Storage Size'

when 23 then  'Bulk Delete Subprocess'

when 24 then  'Update Statistic Intervals'

when 25 then  'Organization Full Text Catalog Index'

when 26 then  'Database log backup'

when 27 then  'Update Contract States'

when 28 then  'DBCC SHRINKDATABASE maintenance job'

when 29 then  'DBCC SHRINKFILE maintenance job'

when 30 then  'Reindex all indices maintenance job'

when 31 then  'Storage Limit Notification'

when 32 then  'Cleanup inactive workflow assemblies'

when 35 then  'Recurring Series Expansion'

when 38 then  'Import Sample Data'

when 40 then  'Goal Roll Up'

when 41 then  'Audit Partition Creation'

when 42 then  'Check For Language Pack Updates'

when 43 then  'Provision Language Pack'

when 44 then  'Update Organization Database'

when 45 then  'Update Solution'

when 46 then  'Regenerate Entity Row Count Snapshot Data'

when 47 then  'Regenerate Read Share Snapshot Data'

when 50 then  'Outgoing Activity'

when 51 then  'Incoming Email Processing'

when 52 then  'Mailbox Test Access'

when 53 then  'Encryption Health Check'

when 54 then  'Execute Async Request'

when 49 then  'Post to Yammer'

when 56 then  'Update Entitlement States'

else cast(operationtype as varchar)

end as 'OperationType',



case statecode

 when 0 then 'Ready'

when 1 then 'Suspended'

when 2 then 'Locked'

when 3 then 'Completed'

else cast (statecode as varchar)

end as 'StateCode',



case statuscode

when 0 then 'Waiting for Resources'

when 10 then 'Waiting'

when 20 then 'In Progress'

when 21 then 'Pausing'

when 22 then 'Canceling'

when 30 then 'Succeeded'

when 31 then 'Failed'

when 32 then 'Canceled'

else cast (statuscode as varchar)

end as 'StatusCode',



Count(*) AS [RecordCount],



case when (OperationType in (1, 9, 12, 25, 27, 10) AND StateCode = 3 AND StatusCode IN (30,32) ) then 'Yes' else 'No' end as 'Removable'



FROM AsyncOperationBase

WHERE StartedOn IS NOT NULL

GROUP BY Name, DATEPART(YEAR,CreatedOn), DATEPART(MONTH,CreatedOn), OperationType, StatusCode, StateCode

having Count(*) > @threshold

order by 2, 3



CrmDuplicateRecordException Error 0x80040237 “Cannot insert duplicate key.” during import of CRM Solution

So when you import a solution, then this leads to error 0x80040237 “Cannot insert duplicate key.”? Then download the solution import XML log file, open in Excel, and have a look at the name of the troubled entity.


Then unzip solution ZIP and open the customizations.xml. Find the troubled entity, the easiest is to search for:

<entity Name="[yourentity]">

Within this entity you should find something similar to this:

<CustomControlDefaultConfigs>

        <CustomControlDefaultConfig>

          <PrimaryEntityTypeCode>10046</PrimaryEntityTypeCode>

          <CustomControlDefaultConfigId>{924314e7-3e47-e614-80de-fc15b4269a54}</CustomControlDefaultConfigId>

          <ControlDescriptionXML><controlDescriptions /></ControlDescriptionXML>

          <IntroducedVersion>2016.07.6.1</IntroducedVersion>

        </CustomControlDefaultConfig>

      </CustomControlDefaultConfigs>

The PrimaryEntityTypeCode is from the origin/source environment. In the target environment, the PrimaryEntityTypeCode is different. This usually isn’t an issue, but somehow the system can get confused. Most likely you’ll find that the Guid for this CustomControlDefaultConfigId appears for two different PrimaryEntityTypeCodes in the target system. You can confirm this using this query:

SELECT PrimaryEntityTypeCode, * FROM CustomControlDefaultConfigBase WHERE CustomControlDefaultConfigId = '[your guid]'

If you indeed see records with different PrimaryEntityTypeCode and the same CustomControlDefaultConfigId, then this is indeed the issue. The one which doesn’t match the code from the XML file, in this example 10046, is the one from the origin environment, the other from the target environment. We should get rid of the one which matches the origin environment.

DELETE FROM CustomControlDefaultConfigBase WHERE CustomControlDefaultConfigId = '[your guid] AND PrimaryEntityTypeCode = '[PrimaryEntityTypeCode from customizations.xml]'

If after fixing this bug you’re faced with another error on the same entity, with the message ‘There should not be more than one component instance for a solution being upgraded’, then it’s getting more challenging. My advice? Contact Microsoft Support..



The curse of the deleted workflows

When you’re following a development process including at least a development and production environment, then you might end up in a scenario where you have deleted a workflow from the production environment and then want to import a solution containing the very same workflow.

In some scenario’s you will find that this results in the error message:


0x80041103: Workflow' entity doesn't contain attribute with Name = 'Workflowid'.

Though the error message isn’t valid at all, the workflow entity definitely has the attribute Workflowid, there is an explanation for the error.

What happens when you enable a workflow, is that a copy of the workflow is created in the database, called a ‘Workflow activation’. It is this copy of the workflow that is being used when a workflow is executed. This is useful for when the workflow is being changed, the current workflows will then continue running against this copy of the workflow. Michael B. Scott describes this pretty well in a response on this forum: https://social.microsoft.com/Forums/en-US/b717ae4a-1e5d-48d2-880e-c961ff9a776d/crm-2011-workflows-being-duplicated?forum=crm

He also describes that it takes a while (max 24 hours), before the workflow activation records get deleted when they’re not used anymore. And it is exactly the existence of this workflow activation that causes the error message. This means that in a happy scenario the error should magically disappear within 24 hours.

But, sometime it doesn’t.

In that case there are still references to the workflow activation record. You can find these when searching for system jobs carrying the same name as the name of the workflow. Most likely these are the instances of the workflow that didn’t end with a success state, such as cancelled or failed workflow executions. After deleting these, then another 24 hours later, the workflow activation record should get removed.

But, how to delete these? You are lucky if this works through the CRM UI, but this can throw error messages as well as the related workflow doesn't exist anymore. In that case a bulk delete can give you the answer. Note: I would always strongly favor the CRM UI approach as this handles as much cleaning as possible for you.

But if that doesnt'work and you do have access to the database, then I have some SQL queries that can help identify the records or even clean them server-side.


-- select all records having a non existing parent (most likely only workflow activation records)
Select name, workflowid, parentworkflowid, * from Workflowbase w
where parentworkflowid not in (select workflowid from Workflowbase)
order by 1

-- select all system jobs related to the selected workflow activation records
select asyncoperationid, WorkflowActivationId, WorkflowActivationIdName, CorrelationId, statecode, CreatedOn, completedon, regardingobjectid, regardingobjectidname, regardingobjecttypecode
from AsyncOperation
where WorkflowActivationId IN
       (Select workflowid from Workflow w
       where parentworkflowid not in (select workflowid from Workflow))
order by workflowactivationid, CompletedOn

-- find out how many workflowlog records (basically steps in a workflow) are related to the workflow instances
select count(*) from workflowlog
where AsyncOperationId IN
       (select asyncoperationid from AsyncOperation
       where WorkflowActivationId IN
             (Select workflowid from Workflow w
             where parentworkflowid not in (select workflowid from Workflow)
             )
       )

Enjoy



Unlimited redirects or popups to https://www.crmdynint.com

Hi guys,

We've recently seen a situation where users of Dynamics365 (a.k.a. CRM Online) are getting popups or redirects to an url such as:

 
With the support of Microsoft support we have been able to solve this issue by adding the following sites to the trusted sites of Internet Explorer:
 
And to remove the temporary files from Internet Explorer as well as the folder "%temp%".
 
Keith Cockerham has identified the guided learning path as the cause of this issue. Turning off this feature using another browser is another workaround for this issue, but keep in mind that obviously you cannot use the guided learning path feature in this scenario.



A managed solution cannot overwrite the AttributeMap component with Id=[guid] which has an unmanaged base instance

Facing this message?

A managed solution cannot overwrite the AttributeMap component with Id=b648bf03-102f-e611-80d3-e1543fac8121 which has an unmanaged base instance. The most likely scenario for this error is that an unmanaged solution has installed a new unmanaged AttributeMap component on the target system, and now a managed solution from the same publisher is trying to install that same AttributeMap component as managed. This will cause an invalid layering of solutions on the target system and is not allowed.

Then you can quickly find the problematic mapping using the following query:

select SourceEntityName, SourceAttributeName, TargetEntityName, TargetAttributeName from AttributeMap am
left outer join entitymap em on em.entitymapid = am.EntityMapId
where am.AttributeMapId='b648bf03-102f-e611-80d3-e1543fac8121'

Just remove the mapping from the target system and reimport the solution and you're ready to go.