CRM 2013: Cannot specify child attribute retrieve – MergeRequest C#

Hello!

If you are working on code to merge two entity records and come across “Cannot specify child attribute retrieve” error; and you have referred SDK/MSDN documentation. You probably have kept UpdateContent property optional and havent set it. UpdateContent is a required property though the documentation says it is not.

This property is optional in case of merging incidents only.

You just have to set Entity object to UpdateContent property which has attributes to be updated to the merged record.

Entity contact = new Entity("contact");
contact["firstname"] = "Crm";
contact["lastname"] = "Xpress";
 
// merging contact records
MergeRequest merge = new MergeRequest
{
    // SubordinateId is the GUID of the contact merging.
    SubordinateId = contactId,
    Target = target,
    PerformParentingChecks = true,
    UpdateContent = contact // Entity Object to set the content you want updated on the merged contact
};

HTH!
Happy Merging!

Advertisements

CRM 2011 C#: Get List of User Security Roles

Hello guys,

Use below method to get the list of Security Roles that the logged in user belongs to.

A WhoAmIRequest and WhoAmIResponse messages are used to get the current logged in user’s GUID. I have used a FetchXml technique to get the Roles list. The primary entity role is used and a related entity systemuserroles is used to relate the records and a condition is given on the same entity to find the logged in user’s related records.

private List<string> RetrieveSecurityRoles()
{
	List<string> rolesList = new List<string>();
	string fetchXml = @"<fetch mapping=""logical"" count=""50"" version=""1.0"">
							<entity name=""role"">
								<attribute name=""name"" />
								<link-entity name=""systemuserroles"" from=""roleid"" to=""roleid"">
									<filter>
										<condition attribute=""systemuserid"" operator=""eq"" value=""{0}"" />
									</filter>
								</link-entity>
							</entity>
						</fetch>";
	fetchXml = string.Format(fetchXml, ((WhoAmIResponse)oHelper._crmservice.Execute(new WhoAmIRequest())).UserId);
	var result = oHelper._crmservice.RetrieveMultiple(new FetchExpression(fetchXml));

	foreach (var item in result.Entities)
	{
		rolesList.Add(item.Attributes["name"].ToString());
	}

	return rolesList;
}

Hope this helps!!

C# Winforms TableLayoutPanel middle align the control

TableLayoutPanel control represents a panel that dynamically lays out its contents in a table format. You want to use a TableLayoutPanel in complex and sophisticated applications where you need to create dynamic layouts.TableLayoutPanel

By default when you add controls to the TableLayoutPanel, it sets them to the top left corner. When you want to align these controls (for exam, Button) to be middle, Set the value of the Button control’s Anchor property to None. The Button control moves to the center of the cell.