Freigeben über


SearchRequest Class

Definition

Contains the data needed to search for available time slots that fulfill the specified appointment request.

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

This example expects that you have a plumber service and a van resource with the specified ID values.

/// <summary>
/// Demonstrates the SearchRequest message with AppointmentRequest class
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance</param>
static void SearchRequestExample(IOrganizationService service) {

      // The ID of a plumber service
      Guid plumberServiceId = new("61f2e2cc-005b-4585-b19a-36d74d169a43");

      // Create the van required resource object.
      RequiredResource vanReq = new()
      {
         ResourceId = new Guid("27cad8ab-5e46-4b34-9159-436a7475ac36"),
         ResourceSpecId = new Guid("001f0221-14e4-48e3-9256-11943533aa7f")
      };

      // Create the appointment request.
      AppointmentRequest appointmentReq = new()
      {
         RequiredResources = new RequiredResource[] { vanReq },
         Direction = SearchDirection.Backward,
         Duration = 60,
         NumberOfResults = 10,
         ServiceId = plumberServiceId,
         // The search window describes the time when the resouce can be scheduled.
         // It must be set.
         SearchWindowStart = DateTime.Now.ToUniversalTime(),
         SearchWindowEnd = DateTime.Now.AddDays(7).ToUniversalTime(),
         UserTimeZoneCode = 1
      };

      // Compose the request         
      SearchRequest request = new()
      {
         AppointmentRequest = appointmentReq
      };
      // Send the request
      var reponse = (SearchResponse)service.Execute(request);

      if (reponse.SearchResults.Proposals.Length > 0)
      {
         Console.WriteLine("Openings are available to schedule the resource.");
      }
}

Remarks

For the Web API use the Search function.

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

Notes for Callers

This message will return a set of available appointments as time blocks.

Constructors

SearchRequest()

Initializes a new instance of the SearchRequest class.

Properties

AppointmentRequest

Gets or sets the appointment request.

ExtensionData

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

(Inherited from OrganizationRequest)
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)

Applies to

See also