QuerySchedule Message (CrmService)
![]() |
[Applies to: Microsoft Dynamics CRM 4.0]
Find the latest SDK documentation: CRM 2015 SDK
| Works for all deployment types | Works online and offline |
Searches the specified resource for an available time slot matching the specified parameters.
The relevant classes are specified in the following table.
| Type | Class |
| Request | QueryScheduleRequest |
| Response | QueryScheduleResponse |
| Entity | resource |
Remarks
To use this message, pass an instance of the QueryScheduleRequest class as the request parameter in the Execute method.
To perform this action, the caller must have access rights on the entity instance specified in the request class. For a list of required privileges, see QuerySchedule Privileges.
Example
The following code example shows how to use the QuerySchedule message.
[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;
// The user whose schedule is being retrieved.
Guid resource = user.UserId;
// Create the request object.
QueryScheduleRequest schedule = new QueryScheduleRequest();
// Set the properties of the request object.
schedule.ResourceId = resource;
schedule.Start = new CrmDateTime();
schedule.Start.Value = "2005-01-01T00:00:00";
schedule.End = new CrmDateTime();
schedule.End.Value = "2005-01-08T00:00:00";
schedule.TimeCodes = new TimeCode[]{TimeCode.Available};
// Execute the request.
QueryScheduleResponse scheduled = (QueryScheduleResponse)service.Execute(schedule);
[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
' The user whose schedule is being retrieved.
Dim resource As Guid = user.UserId
' Create the request object.
Dim schedule As New QueryScheduleRequest()
' Set the properties of the request object.
schedule.ResourceId = resource
schedule.Start = New CrmDateTime()
schedule.Start.Value = "2005-01-01T00:00:00"
schedule.End = New CrmDateTime()
schedule.End.Value = "2005-01-08T00:00:00"
schedule.TimeCodes = New TimeCode() {TimeCode.Available}
' Execute the request.
Dim scheduled As QueryScheduleResponse = CType(service.Execute(schedule), QueryScheduleResponse)
See Also
Concepts
Reference
.gif)