Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

RetrieveMultiple 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

Retrieves a collection of business entity instances of a specified type based on query criteria.

The relevant classes are specified in the following table.

TypeClass
RequestRetrieveMultipleRequest
ResponseRetrieveMultipleResponse
EntitySee the following table.

The following table shows the entities that support this message.

EntityTarget class
accountTargetRetrieveAccount
activitypointerTargetRetrieveActivityPointer
annotationTargetRetrieveAnnotation
annualfiscalcalendarTargetRetrieveAnnualFiscalCalendar
appointmentTargetRetrieveAppointment
bulkdeleteoperationTargetRetrieveBulkDeleteOperation
bulkdeletefailureTargetRetrieveBulkDeleteFailure
businessunitTargetRetrieveBusinessUnit
businessunitnewsarticleTargetRetrieveBusinessUnitNewsArticle
calendarTargetRetrieveCalendar
campaignTargetRetrieveCampaign
campaignactivityTargetRetrieveCampaignActivity
campaignresponseTargetRetrieveCampaignResponse
competitorTargetRetrieveCompetitor
constraintbasedgroupTargetRetrieveConstraintBasedGroup
contactTargetRetrieveContact
contractTargetRetrieveContract
contractdetailTargetRetrieveContractDetail
contracttemplateTargetRetrieveContractTemplate
customeraddressTargetRetrieveCustomerAddress
customeropportunityroleTargetRetrieveCustomerOpportunityRole
customerrelationshipTargetRetrieveCustomerRelationship
discountTargetRetrieveDiscount
discounttypeTargetRetrieveDiscountType
duplicaterecordTargetRetrieveDuplicateRecord
duplicateruleTargetRetrieveDuplicateRule
duplicateruleconditionTargetRetrieveDuplicateRuleCondition
emailTargetRetrieveEmail
equipmentTargetRetrieveEquipment
faxTargetRetrieveFax
fixedmonthlyfiscalcalendarTargetRetrieveFixedMonthlyFiscalCalendar
incidentTargetRetrieveIncident
incidentresolutionTargetRetrieveIncidentResolution
importTargetRetrieveImport
importfileTargetRetrieveImportFile
importlogTargetRetrieveImportLog
importmapTargetRetrieveImportMap
invoiceTargetRetrieveInvoice
invoicedetailTargetRetrieveInvoiceDetail
kbarticleTargetRetrieveKbArticle
kbarticlecommentTargetRetrieveKbArticleComment
kbarticletemplateTargetRetrieveKbArticleTemplate
leadTargetRetrieveLead
letterTargetRetrieveLetter
listTargetRetrieveList
monthlyfiscalcalendarTargetRetrieveMonthlyFiscalCalendar
opportunityTargetRetrieveOpportunity
opportunitycloseTargetRetrieveOpportunityClose
opportunityproductTargetRetrieveOpportunityProduct
ordercloseTargetRetrieveOrderClose
phonecallTargetRetrievePhoneCall
plugintypeTargetRetrievePluginType
pricelevelTargetRetrievePriceLevel
productTargetRetrieveProduct
productpricelevelTargetRetrieveProductPriceLevel
quarterlyfiscalcalendarTargetRetrieveQuarterlyFiscalCalendar
queueTargetRetrieveQueue
queueitemTargetRetrieveQueueItem
quoteTargetRetrieveQuote
quotecloseTargetRetrieveQuoteClose
quotedetailTargetRetrieveQuoteDetail
relationshiproleTargetRetrieveRelationshipRole
relationshiprolemapTargetRetrieveRelationshipRoleMap
resourceTargetRetrieveResource
resourcegroupTargetRetrieveResourcesGroup
resourcespecTargetRetrieveResourcesSpec
roleTargetRetrieveRole
salesliteratureTargetRetrieveSalesLiterature
salesliteratureitemTargetRetrieveSalesLiteratureItem
salesorderTargetRetrieveSalesOrder
salesorderdetailTargetRetrieveSalesOrderDetail
savedqueryTargetRetrieveSavedQuery
semiannualfiscalcalendarTargetRetrieveSemiAnnualFiscalCalendar
serviceTargetRetrieveService
serviceappointmentTargetRetrieveServiceAppointment
siteTargetRetrieveSite
subjectTargetRetrieveSubject
systemuserTargetRetrieveSystemUser
taskTargetRetrieveTask
teamTargetRetrieveTeam
templateTargetRetrieveTemplate
territoryTargetRetrieveTerritory
uomTargetRetrieveUoM
uomscheduleTargetRetrieveUoMSchedule
userqueryTargetRetrieveUserQuery
Custom entityTargetRetrieveX where X is the name of the custom entity
DynamicEntityTargetRetrieveDynamic

Remarks

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

To perform this action, the caller must have access rights on the specified entity instance. For a list of required privileges, see RetrieveMultiple Privileges.

For better performance, use the RetrieveMultiple method instead of using this message.

Example

The following code examples show how to use the RetrieveMultiple 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;

// Create the column set that indicates the fields to be retrieved.
ColumnSet cols = new ColumnSet();

// Set the properties of the column set.
cols.Attributes = new string [] {"name", "accountid"};

// Create the ConditionExpression.
ConditionExpression condition = new ConditionExpression();

// Set the condition for the retrieval to be when the city in the account's address is Sammamish.
condition.AttributeName = "address1_city";
condition.Operator = ConditionOperator.Like;
condition.Values = new string [] {"Sammamish"};

// Create the FilterExpression.
FilterExpression filter = new FilterExpression();

// Set the properties of the filter.
filter.FilterOperator = LogicalOperator.And;
filter.Conditions = new ConditionExpression[] {condition};

// Create the QueryExpression object.
QueryExpression query = new QueryExpression();

// Set the properties of the QueryExpression object.
query.EntityName = EntityName.account.ToString();
query.ColumnSet = cols;
query.Criteria = filter;

// Create the request object.
RetrieveMultipleRequest retrieve = new RetrieveMultipleRequest();

// Set the properties of the request object.
retrieve.Query = query;
      
// Execute the request.
RetrieveMultipleResponse retrieved = (RetrieveMultipleResponse)service.Execute(retrieve);
[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 column set that indicates the fields to be retrieved.
Dim cols As New ColumnSet()

' Set the properties of the column set.
cols.Attributes = New String() {"name", "accountid"}

' Create the ConditionExpression.
Dim condition As New ConditionExpression()

' Set the condition for the retrieval to be when the city in the account's address is Sammamish.
condition.AttributeName = "address1_city"
condition.[Operator] = ConditionOperator.Like
condition.Values = New String() {"Sammamish"}

' Create the FilterExpression.
Dim filter As New FilterExpression()

' Set the properties of the filter.
filter.FilterOperator = LogicalOperator.And
filter.Conditions = New ConditionExpression() {condition}

' Create the QueryExpression object.
Dim query As New QueryExpression()

' Set the properties of the QueryExpression object.
query.EntityName = EntityName.account.ToString()
query.ColumnSet = cols
query.Criteria = filter

' Create the request object.
Dim retrieve As New RetrieveMultipleRequest()

' Set the properties of the request object.
retrieve.Query = query

' Execute the request.
Dim retrieved As RetrieveMultipleResponse = CType(service.Execute(retrieve), RetrieveMultipleResponse)

Example 2

[C#]
// Return accounts whose owner's last name is not Cannon.

// Create a column set holding the names of the columns to be retrieved.
ColumnSet cols = new ColumnSet();

// Set the properties of the column set.
cols.Attributes = new string [] {"name", "accountid"};

// Create the condition expression.
ConditionExpression condition = new ConditionExpression();

// Set the condition for the retrieval to be when the last name of the account owner is not Cannon.
condition.AttributeName = "lastname";
condition.Operator = ConditionOperator.NotEqual;
condition.Values = new string [] {"Cannon"};

// Build the filter based on the condition.
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.And;
filter.Conditions = new ConditionExpression[] {condition};

// Create a LinkEntity to link the owner's information to the account.
LinkEntity link = new LinkEntity();

// Set the properties of the LinkEntity.
link.LinkCriteria = filter;

// Set the linking entity to be the account.
link.LinkFromEntityName = EntityName.account.ToString();

// Set the name of the attribute being linked to.
link.LinkFromAttributeName = "owninguser";

// Set the entity being linked to be the systemuser.
link.LinkToEntityName = EntityName.systemuser.ToString();

// Set the attribute linking to the systemuser to be the owninguser.
link.LinkToAttributeName = "systemuserid";

// Create the query.
QueryExpression query = new QueryExpression();

// Set the properties of the query.
query.EntityName = EntityName.account.ToString();
query.ColumnSet = cols;
query.LinkEntities = new LinkEntity[] {link};

// Create the request object.
RetrieveMultipleRequest retrieve = new RetrieveMultipleRequest();

// Set the properties of the request object.
retrieve.Query = query;

// Execute the request.
RetrieveMultipleResponse retrieved2 = (RetrieveMultipleResponse) service.Execute(retrieve);

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2015 Microsoft