[CRM 2016] Error code #0x80040237. Error while solution import. Cannot insert duplicate key.

We were deploying from sandbox to production with one of the solutions. And for no reason, the solution import failed on all attempts with error code #0x80040237. And there was not much description given except – “Cannot insert duplicate key”. This was the error on one of the entities.

First, we followed a post by a friend on the same error. We even removed some data to check if that is the case. But, the import failed again with the same error code and description.

Then, we came across similar question on MSDN. Question was already showing an answer that by removing <CustomControlDefaultConfigs> section from Solution.xml this can be resolved. This issue is already taken care on Dynamics 365. However, CRM 2016 Online, this issue still persists.

Resolution:

  • Extract your solution zip file.
  • Open solution.xml file in a text editor.
  • Search for the <entity></entity> tag for the entity on which your solution import is showing the error.
  • Find and remove <CustomControlDefaultConfigs> section inside the <entity> section.
  • Save the solution.xml file and create new zip file from the extracted solution contents.
  • Import will be successful this time!!

The reason to remove <CustomControlDefaultConfigs> section from solution.xml file is still not known. And there are other option also available like updating sql to resolve this error for on premise deployments. However, CRM Online users do not have any option but to modify solution.xml file.

Hope this helps!

Advertisements

Access to Microsoft Dynamics CRM has not yet been fully configured for this user. The user needs at least one security role before you can continue.

I ran into an issue when I was importing a different version  of solution to the organization. The error was:

Access to Microsoft Dynamics CRM has not yet been fully configured for this user. The user needs at least one security role before you can continue.

I was not able to find anything on google/bing for the specific error, but one of the blog I found said the error can be from business rules or other type of processes.

After some research, I came to know that there were multiple Business Rules on the organization which were owned by users who were deactivated and no longer have anything to do with CRM Development.

Resolution:
To resolve this issue, you just  need to assign the Business Processes or other workflows to any active user.

Step 1: Use Advanced Find feature to find the processes and their respective owners.

Advanced Find - Business Rules
Advance Find Business Rules

 

Step 2: Select all results which shows owner who are already disabled.

Advanced Find Result

Advanced Find – Result

Step 3: Assign the Business Rules/Processes to your user account or another user who is in active state.

Assign

Assign processes

And you’re done!! Try to reimport the solution and the error will be gone forever…

CRM 2011: Get list of all Web Resources from the solution using C#

When you do not have WebResource class… When there is no proxy of CRM service added to your project and you are using Late Binding method to connect to Microsoft Dynamics CRM 2011. And you want to get the list of all Web Resources from the given solution. Here is a method to get the List of all Web Resources from the solution passed as a parameter.

Here is what we have in WebResource class:

public class WebResource
{
    /// <summary>
    /// Gets or sets the display name.
    /// </summary>
    /// <value>
    /// The display name.
    /// </value>
    public string DisplayName { get; set; }

    /// <summary>
    /// Gets or sets the web resource id.
    /// </summary>
    /// <value>
    /// The web resource id.
    /// </value>
    public Guid WebResourceId { get; set; }
}

And the method that gets the list of all Web Resources from the Solution is:

public static List<WebResource> GetSolutionRelatedWebResources(IOrganizationService OrgService, object SolutionId)
{
    var fetchQuery = @"<fetch mapping='logical' count='500' version='1.0'>
                        <entity name='webresource'>
                            <attribute name='displayname' />
                            <link-entity name='solutioncomponent' from='objectid' to='webresourceid'>
                                <filter>
                                    <condition attribute='solutionid' operator='eq' value='" + SolutionId + @"' />
                                </filter>
                            </link-entity>
                        </entity>
                    </fetch>";

    EntityCollection result = OrgService.RetrieveMultiple(new FetchExpression(fetchQuery));
    List<WebResource> WebResourceList = new List<WebResource>();

    foreach (var webresource in result.Entities)
    {
        WebResourceList.Add(new WebResource() { DisplayName = webresource.Attributes["displayname"].ToString(), WebResourceId = (Guid)webresource.Attributes["webresourceid"] });
    }

    return WebResourceList;
}

Remember, as you have not created a proxy of the CRM web service and you have not generated any class using crmsvcutil.exe provided in bin directory in SDK, you would want to try the above code.

Happy Programming!

CRM 2011: Create a Solution for a specific Publisher using C#

Hi there!!

When you have not created any proxy from the CRM service; and you want to create a new Solution for a specific Publisher using C# code. You wanna check below code:

public static Guid CreateSolution(IOrganizationService OrgService, string FriendlyName, string UniqueName, Guid PublisherId)
{
    Entity solution = new Entity("solution");
    solution["friendlyname"] = FriendlyName;
    solution["uniquename"] = UniqueName;
    solution["publisherid"] = new EntityReference("publisher", PublisherId);

    Guid ResultId = OrgService.Create(solution);
    return ResultId;
}

You just want to connect to the CRM 2011 system and pass IOrganizationService object to the method and other required information related to Solution along with the PublisherId.

Happy Programming!

CRM 2011: Get List of Solutions from given Publisher using C#

Hi Guys!

Here, I am presenting the method of getting all solutions from a specific publisher passed as a parameter from Microsoft Dynamics CRM 2011.

public static List<Solution> GetSolutionsList(IOrganizationService OrgService, Guid PublisherId)
{
    QueryExpression query = new QueryExpression()
    {
        EntityName = "solution",
        ColumnSet = new ColumnSet(true),
        Criteria = new FilterExpression()
    };

    query.Criteria.AddCondition(new ConditionExpression("publisherid", ConditionOperator.Equal, PublisherId));
    EntityCollection result = OrgService.RetrieveMultiple(query);
    List<Solution> SolutionList = new List<Solution>();

    foreach (var solution in result.Entities)
    {
        if (solution["uniquename"].ToString() != "System" && solution["uniquename"].ToString() != "Active" && solution["uniquename"].ToString() != "Basic" && solution["uniquename"].ToString() != "ActivityFeeds")
        {
            SolutionList.Add(
                new Solution()
                {
                    Id = (Guid)solution["solutionid"],
                    Name = solution["friendlyname"].ToString(),
                    PublisherId = ((EntityReference)solution["publisherid"]).Id,
                    UniqueName = solution["uniquename"].ToString()
                });
        }
    }

    return SolutionList;
}

And the Solution Class is defined as:

/// <summary>
/// Solution Class
/// </summary>
public class Solution
{
    /// <summary>
    /// Gets or sets the name.
    /// </summary>
    /// <value>
    /// The name of solution.
    /// </value>
    public string Name { get; set; }

    /// <summary>
    /// Gets or sets the id.
    /// </summary>
    /// <value>
    /// The id of solution.
    /// </value>
    public Guid Id { get; set; }

    /// <summary>
    /// Gets or sets the name of the unique.
    /// </summary>
    /// <value>
    /// The name of the unique.
    /// </value>
    public string UniqueName { get; set; }

    /// <summary>
    /// Gets or sets the publisher id.
    /// </summary>
    /// <value>
    /// The publisher id.
    /// </value>
    public Guid PublisherId { get; set; }
}

I want to specify that this code is used when CRM service proxy is not created in the project. You need to create an IOrganizationService object when you have connected to the CRM 2011 system and passing it to the method I have provided above.

Happy Programming!