2 is not a valid state code on product with Id – Error while trying to create a new Product record in CRM 2015 Upgraded Environment


Hi

Recently we upgraded one of our CRM 2013 Online to CRM 2015 Online Update 1. The approach was installing the solution from our dev to new CRM 2015 environment.

After the update when trying to create a new product we were getting the following error message

“2 is not a valid state code on product with Id 0977da8e-3368-e511-80fc-3863bb359f30”

We raised the support ticket and the resolution was to add the following line of code to the customization.xml file. It seemed that few of the State Code and Status Code were gone missing for the product entity.

Adding them back resolved the issue.

Hope it helps..

No plugins have been selected from the list. Please select at least one and try again error while trying to register Custom Workflow Activity in CRM 2013 Online.


Hi,

Update – Check if the class used for defining Plugin / Workflow Activitiy is PUBLIC

Was getting below error while trying to register Custom Workflow Activity in CRM 2013 Online.

The solution we found out was to use CRM 2015’s Plugin Registration Tool to register it.

Hope it helps.

Advertisements

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


Hi,

We were getting the error while importing a managed solution exported from dev environment to the test environment in CRM 2013 online.

It might be the case that the particular report was modified by the user in the test environment. As we weren’t updating that report we removed that report from the new exported managed solution from our dev environment and the import was successful.

https://sliong.wordpress.com/2012/09/20/crm-2011-importing-managed-solution-error-a-managed-solution-cannot-overwrite-the-attribute-component/

Hope it helps.

Sample code to check if User is a member of a team C# CRM 2011/2013/2015


Sharing sample code to check if a user belongs to a team or not


public static bool IsTeamMember(Guid teamID, Guid userID, IOrganizationService service)
{
QueryExpression query = new QueryExpression("team");
query.ColumnSet = new ColumnSet(true);
query.Criteria.AddCondition(new ConditionExpression("teamid", ConditionOperator.Equal, teamID));
LinkEntity link = query.AddLink("teammembership", "teamid", "teamid");
link.LinkCriteria.AddCondition(new ConditionExpression("systemuserid", ConditionOperator.Equal, userID));
var results = service.RetrieveMultiple(query);

if (results.Entities.Count > 0)
{
return true;
}
else
{
return false;
}
}

Hope it helps.

Sample code to read XML Data from Web Resource in Plugin in CRM 2011/2013/2015


We recently had a requirement to read xml data stored in a particular web resource in plugin.

Sharing the sample code


public static Dictionary<string, string> GetMarketClusterAndMarketSegment(string webresourceName, string buildingTypeValue, IOrganizationService organizationService)
{
Dictionary<string, string> dictionaryMarket = new Dictionary<string, string>();

// tk_et_oppline_marketingfilterpicklists
// create request to retrieve Webresource
ColumnSet cols = new ColumnSet();
cols.AddColumn("content");
QueryByAttribute requestWebResource = new QueryByAttribute
{
EntityName = "webresource",
ColumnSet = cols
};
requestWebResource.Attributes.AddRange("name");
requestWebResource.Values.AddRange(webresourceName);

Entity webResourceEntity = null;
EntityCollection webResourceEntityCollection = organizationService.RetrieveMultiple(requestWebResource);

if (webResourceEntityCollection.Entities.Count > 0)
{
webResourceEntity = webResourceEntityCollection.Entities[0];
byte[] binary = Convert.FromBase64String(webResourceEntity.Attributes["content"].ToString());
string resourceContent = System.Text.Encoding.UTF8.GetString(binary);
string byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
if (resourceContent.StartsWith(byteOrderMarkUtf8))
{
resourceContent = resourceContent.Remove(0, byteOrderMarkUtf8.Length);
}

XDocument xmlDocument = XDocument.Parse(resourceContent);

var marketSegment = from t in xmlDocument.Descendants("ParentField").ElementAt(1).Descendants("ShowOption")
where t.Attribute("value").Value.Equals(buildingTypeValue)
select new
{
marketSegmentValue = t.Parent.Attribute("value").Value,
marketSegmentLabel = t.Parent.Attribute("label").Value
};

foreach (var v in marketSegment)
{
dictionaryMarket.Add("marketsegment", v.marketSegmentValue);
var marketCluster = from t in xmlDocument.Descendants("ParentField").ElementAt(0).Descendants("ShowOption")
where t.Attribute("value").Value.Equals(v.marketSegmentValue)
select new
{
marketClusterValue = t.Parent.Attribute("value").Value,
marketClusterLabel = t.Parent.Attribute("label").Value
};

foreach (var m in marketCluster)
{
dictionaryMarket.Add("marketcluster", m.marketClusterValue);
}
}
}

return dictionaryMarket;
}
}

Hope it helps..

You cannot send email as the selected user. The selected user has not allowed this or you do not have sufficient privileges to do so. Contact your system administrator for assistance. Error in CRM 2013/2015


Was getting the below error in one of the custom workflow activity we were using for sending email.

To fix the issue,

Login to CRM with the user selected as From.

Open Set Personal Options box

And check the check box “Allow other Microsoft Dynamics CRM users to send email on your behalf”

Hope it helps..