locked
How to get account entity component type in MS dynamics CRM? RRS feed

  • Question

  • Hi,

    I want to add a solution component to my solution using CRM SDK 2011. I am using AddSolutionComponentRequest Class to add a component to solution, but I was strucked how to get account entity component type to assign to property of AddSolutionComponentRequest. How can I able to get it.

     

    Following is the code I am using to add solution component

     

    RetrieveEntityRequest retrieveForAddAccountRequest = new RetrieveEntityRequest()
                {
                    LogicalName = "account"
                };
                RetrieveEntityResponse retrieveForAddAccountResponse = (RetrieveEntityResponse)osp.Execute(retrieveForAddAccountRequest);
    
                QueryExpression SolutionRetrievalQuery = new QueryExpression
                {
                    EntityName="solution",
                    ColumnSet= new ColumnSet("uniquename")
                };
    
                EntityCollection SolutionListEntities = osp.RetrieveMultiple(SolutionRetrievalQuery);
    
                AddSolutionComponentRequest addReq = new AddSolutionComponentRequest()
                {
                    ComponentType = (int)
                    ComponentId = (Guid)retrieveForAddAccountResponse.EntityMetadata.MetadataId,
                    SolutionUniqueName =Convert.ToString(SolutionListEntities.Entities[5]["uniquename"])
                };
                osp.Execute(addReq);


    Karthik

    Friday, October 25, 2013 10:21 AM

All replies

  • // Add an existing Solution Component//Add the Account entity to the solution
    RetrieveEntityRequest retrieveForAddAccountRequest = new RetrieveEntityRequest()
    {
        LogicalName = Account.EntityLogicalName
    };
    RetrieveEntityResponse retrieveForAddAccountResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveForAddAccountRequest);
    AddSolutionComponentRequest addReq = new AddSolutionComponentRequest()
    {
        ComponentType = (int)componenttype.Entity,
        ComponentId = (Guid)retrieveForAddAccountResponse.EntityMetadata.MetadataId,
        SolutionUniqueName = solution.UniqueName
    };
    _serviceProxy.Execute(addReq);


    The integer value of the componenttype enumeration.Componenttype option value "1" is for "Entity".

    yo can also visit this link for better understanding...

    Component Type (componenttype)

    http://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.addsolutioncomponentrequest.aspx


    Muhammad Sohail





    • Edited by sohail450 Saturday, October 26, 2013 6:47 PM
    • Proposed as answer by Michael D. Mayo Friday, November 1, 2013 9:35 PM
    Saturday, October 26, 2013 5:53 PM