Compartir a través de


AddSolutionComponentRequest Class

Definition

Contains the data that is needed to add a solution component to an unmanaged solution.

public ref class AddSolutionComponentRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")]
public sealed class AddSolutionComponentRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")>]
type AddSolutionComponentRequest = class
    inherit OrganizationRequest
Public NotInheritable Class AddSolutionComponentRequest
Inherits OrganizationRequest
Inheritance
AddSolutionComponentRequest
Attributes

Examples

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface instance.

The following code example adds the contact entity to a solution that is specified in the SolutionUniqueName property.

/// <summary>
/// Demonstrates adding a solution component to a solution
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance</param>
/// <param name="solutionUniqueName">The unique name of the solution</param>
static void AddContactTableToSolution(IOrganizationService service, string solutionUniqueName)
{
      // Retrieve the table definition to get the ID
      RetrieveEntityRequest tableRequest = new()
      {
         LogicalName = "contact"
      };
      var tableResponse = (RetrieveEntityResponse)service.Execute(tableRequest);

      Guid contactTableId = tableResponse.EntityMetadata.MetadataId.Value;

      AddSolutionComponentRequest request = new()
      {
         ComponentType = 1, //Entity is a known component type
         ComponentId = contactTableId,
         SolutionUniqueName = solutionUniqueName
      };

   var response = (AddSolutionComponentResponse)service.Execute(request);

   Console.WriteLine($"Solution Component ID:{response.id}");
}

Remarks

For the Web API use the AddSolutionComponent action.

Usage

Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of AddSolutionComponentResponse class.

Privileges and Access Rights

To perform this action, the caller must have the system administrator or system customizer security role.

Notes for Callers

You can use this message when you know the appropriate ComponentType integer value to use. Most common component types are in the global optionset named componenttype, which is used as the source for the SolutionComponent.ComponentType Choice column. But not all solution components use these types. Some newer component types are not in this list. You can't use this message when you don't know the correct solution component type to use.

Instead of using this message, you should create or update the solution component for a specific solution. When you use this technique, you add the solution component to both the default solution and the specified solution. You can implement the specific-solution technique in two ways.

Use the SolutionUniqueName parameter on the solution component create and update requests.

For solution components that have a create or update request message that includes the SolutionUniqueName property, passing the unique name of the solution adds the solution component to that solution. The following messages include a SolutionUniqueName property:

Pass the SolutionUniqueName optional parameter to the CreateRequest or UpdateRequest.

For other solution components, add SolutionUniqueName as a parameter to the OrganizationRequest.Parameters property when you use the CreateRequest or UpdateRequest messages. For more information, Associate a solution component with a solution using an optional parameter

Supported Tables

This message can only be used for tables that represent solution components.

Adding Application Ribbons to a Solution

When you use AddSolutionComponentRequest to add application ribbons to your solution, you must make sure to include the RibbonCustomization solution component that is associated with the active solution. Use the Active Solution.SolutionId (FD140AAE-4DF4-11DD-BD17-0019B9312238) in the query you use to retrieve the RibbonCustomization record.

/// <summary>
/// Demonstrates retrieving ribbon customizations from the active solution
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance</param>
static void RetrieveActiveRibbonCustomizationExample(IOrganizationService service)
{
      Guid activeSolutionId = new("FD140AAE-4DF4-11DD-BD17-0019B9312238");

      QueryExpression query = new QueryExpression("ribboncustomization")
      {
         ColumnSet = new ColumnSet("ribboncustomizationid"),
         Criteria = new FilterExpression()
      };
      query.Criteria.AddCondition("entity", ConditionOperator.Null);
      query.Criteria.AddCondition("solutionid", ConditionOperator.Equal, activeSolutionId);

      EntityCollection RibbonCustomizations = service.RetrieveMultiple(query);
      Entity response = RibbonCustomizations.Entities[0];
      Guid id = response.GetAttributeValue<Guid>("ribboncustomizationid");
      Console.WriteLine($"ribboncustomizationid: {id}");
}

Constructors

AddSolutionComponentRequest()

Initializes a new instance of the AddSolutionComponentRequest class.

Properties

AddRequiredComponents

Gets or sets a value that indicates whether other solution components that are required by the solution component that you are adding should also be added to the unmanaged solution. Required.

ComponentId

Gets or sets the ID of the solution component. Required.

ComponentType

Gets or sets the value that represents the solution component that you are adding. Required.

DoNotIncludeSubcomponents

Indicates whether the subcomponents should be included.

ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
IncludedComponentSettingsValues

Gets or sets a value that specifies if the component is added to the solution with its metadata.

Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RequestId

Gets or sets the ID of the request. Optional.

(Inherited from OrganizationRequest)
RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
SolutionUniqueName

Gets or sets the unique name of the solution you are adding the solution component to. Required.

Applies to

See also