ExecuteByIdSavedQuery Message (CrmService)
Collapse the table of content
Expand the table of content

ExecuteByIdSavedQuery Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment typesWorks online and offline

Executes a saved query (view) that has the specified ID.

The relevant classes are specified in the following table.



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

To perform this action the caller must have access rights on the entity instances retrieved. For a list of required privileges, see ExecuteByIdSavedQuery Privileges.

This message returns a String type that specifies the XML data containing the results of the query. This XML string is in the following format:

<resultset> + <result>result1</result><result>result2</result> + ... + </resultset> 

The XML string returned from this method may contain multiple entity instances. If no instances are returned, the method simply returns an XML document for the entity type, with no data.

The XML string returned from this method does not contain elements for attributes where the value is null or contains empty strings. This improves performance by not sending more XML data than is necessary from the server to the client.


The following code example demonstrates how to use the ExecuteByIdSavedQuery message.

// 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 request.
ExecuteByIdSavedQueryRequest query = new ExecuteByIdSavedQueryRequest();
query.EntityId = new Guid("4463D991-F88C-4737-8D66-017C31C7B0ED");

// Execute the request.
ExecuteByIdSavedQueryResponse queried = (ExecuteByIdSavedQueryResponse) service.Execute(query);
[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 request.
Dim query As New ExecuteByIdSavedQueryRequest()
query.EntityId = New Guid("4463D991-F88C-4737-8D66-017C31C7B0ED");

' Execute the request.
Dim queried As ExecuteByIdSavedQueryResponse = CType(service.Execute(query), ExecuteByIdSavedQueryResponse)

See Also



© 2010 Microsoft Corporation. All rights reserved.

© 2015 Microsoft