简体   繁体   English

如何使用OrganizationService在Dynamics CRM中搜索特定记录?

[英]How can I search Dynamics CRM using OrganizationService for a specific record?

If I know the accountId of a record I can do something like this: 如果我知道记录的accountId,则可以执行以下操作:

 Dim cols As New ColumnSet(New String() {"name",
                                         "address1_postalcode",
                                         "lastusedincampaign"})
 Dim retrievedAccount As Account = _orgService.Retrieve("account", _accountId, cols).ToEntity(Of Account)()

But what if I don't know the accountId and instead want to search for a record based on some other factor? 但是,如果我不知道accountId而是想根据其他因素搜索记录怎么办? Say, returning all records with "John" as the first name? 说,返回所有以“ John”为名字的记录?

You have to use the RetrieveMultiple method with a QueryExpression. 您必须对QueryExpression使用RetrieveMultiple方法。

See this link for some examples 请参阅此链接以获取一些示例

You could also use Linq to CRM, or Fetch XML. 您还可以使用Linq来CRM或Fetch XML。

You can use QueryExpression as explained here: 您可以按照以下说明使用QueryExpression:

http://msdn.microsoft.com/en-us/library/gg328300.aspx . http://msdn.microsoft.com/zh-CN/library/gg328300.aspx

You can write your own ConditionExpression or FetchXml for the QueryExpression. 您可以为QueryExpression编写自己的ConditionExpression或FetchXml。

For more complicated query I like to use FetchXml. 对于更复杂的查询,我喜欢使用FetchXml。 You can do Advanced Find then download the generated FetchXml, or use any number of online tools like Fetch Xml Builder to generate it first. 您可以执行“高级查找”,然后下载生成的FetchXml,或者使用任意数量的在线工具(例如Fetch Xml Builder)首先生成它。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM