how to insert resource especially System User into Resource Group in Microsoft CRM 2011 SDK

Hi Again,

First,we have to get deep technical information about Constraint definition file;
here is the definition in XML format;

        resource["Id"] == {ac8e6996-ef65-e211-bc9b-005056820011} ||
        resource["Id"] == {4a65de5a-d763-e211-bc9b-005056820011} ||
        resource["Id"] == {626E49EC-2011-E211-84B5-005056820011}
        <Parameter name="resource"/>

Body tag refers to any resources in the Resource Group.
if you add primary key as guid for the record  to the constraint with 'or' logical word, you will see them in the selected resource group in CRM

You can get inspiration from AddMembersToTheConstraint methods as shown bolew,Method takes  constraints string and id of member to be added , parses XML and inserts id's.

 private string AddMembersToTheConstraint(string constraints, Guid[] ids)

            XmlDocument doc = new XmlDocument();
            XmlNodeList body = doc.GetElementsByTagName("Body");
            String MemberLists = body[0].FirstChild.InnerText;
            foreach (Guid id in ids)
                if (MemberLists.ToLower().IndexOf("false") >= 0)
                    MemberLists = "";//Group has not got any member yet.
                    MemberLists += "resource[\"Id\"] == {" + id.ToString() + "}";
                    MemberLists += " || " + "resource[\"Id\"] == {" + id.ToString() + "}";
            body[0].FirstChild.InnerText = MemberLists;

            using (var stringWriter = new StringWriter())
            using (var xmlTextWriter = XmlWriter.Create(stringWriter))
                return stringWriter.GetStringBuilder().ToString();

here is code that you may use while inserting resource(s) to the Resource Group
                resourcegroupGuide.Constraints = AddMembersToTheConstraint(resourcegroupGuide.Constraints, new Guid[] { user.Id });

                if (!context.IsAttached(resourcegroupGuide))

if you need more information about 'context' and '_serviceProxy' objects in the sample code.Please follow :

good luck,


Popular posts from this blog

Assembly Microsoft.Dynamics.Service.Plugins.dll can not be loaded. Dynamics CRM 365 Engine version 9 - CRM User creation error

Exception caught instantiating TERADATA report server extension SQL Reporting Services

Could not load file or assembly 'System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified at Configuration class initiation in