Export (0) Print
Expand All
Expand Minimize

Search Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Searches for available time slots that fulfill the specified appointment request and returns a set of available appointment instances (as time blocks). The method is available on resource and service entities.

The relevant classes are specified in the following table.

TypeClass
RequestSearchRequest
ResponseSearchResponse

Remarks

To use this message, pass an instance of the SearchRequest class as the request parameter in the Execute method.

For a list of required privileges, see Search Privileges.

Example

[C#]
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the appointment request.
AppointmentRequest appointmentReq = new AppointmentRequest();
appointmentReq.RequiredResources = new RequiredResource[] {vanReq};
appointmentReq.Direction = SearchDirection.Forward;
appointmentReq.Duration = 60;
appointmentReq.NumberOfResults = 10;
appointmentReq.NumberOfResults = 1;
appointmentReq.ServiceId = plumberServiceId;

// The search window describes the time when the resource can be scheduled.
// It must be set.
appointmentReq.SearchWindowStart = new CrmDateTime();
appointmentReq.SearchWindowStart.Value = DateTime.Now.ToUniversalTime().ToString();
appointmentReq.SearchWindowEnd = new CrmDateTime();
appointmentReq.SearchWindowEnd.Value = DateTime.Now.AddDays(7).ToUniversalTime().ToString();
appointmentReq.UserTimeZoneCode = 1;

// Create the request object.
SearchRequest search = new SearchRequest();

// Set the properties of the request object.
search.AppointmentRequest = appointmentReq;

// Execute the request.
SearchResponse searched = (SearchResponse)service.Execute(search);
[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the appointment request.
Dim appointmentReq As New AppointmentRequest()
appointmentReq.RequiredResources = New RequiredResource() {vanReq}
appointmentReq.Direction = SearchDirection.Forward
appointmentReq.Duration = 60
appointmentReq.NumberOfResults = 10
appointmentReq.NumberOfResults = 1
appointmentReq.ServiceId = plumberServiceId

' The search window describes the time when the resouce can be scheduled.
' It must be set.
appointmentReq.SearchWindowStart = New CrmDateTime()
appointmentReq.SearchWindowStart.Value = DateTime.Now.ToUniversalTime().ToString()
appointmentReq.SearchWindowEnd = New CrmDateTime()
appointmentReq.SearchWindowEnd.Value = DateTime.Now.AddDays(7).ToUniversalTime().ToString()
appointmentReq.UserTimeZoneCode = 1

' Create the request object.
Dim search As New SearchRequest()

' Set the properties of the request object.
search.AppointmentRequest = appointmentReq

' Execute the request.
Dim searched As SearchResponse = CType(service.Execute(search), SearchResponse)

See Also

Concepts

Reference

Tasks


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft