AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 14.09.2009, 11:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,487 / 846 (79) +++++++
Регистрация: 28.10.2006
crmdude: Querying a PartyList field
Источник: http://crmdude.wordpress.com/2009/08...rtylist-field/
==============


CRM doesn’t allow a PartyList field to be queried using a QueryExpression (it doesn’t allow it using Advanced Find either). A colleague had tried to query the Campaign Response records to ascertain whether a Contact had responded to a Campaign before before performing some other process(es).

The trick was to query the Activity Pointer entity (where the regardingobjectid is the Campaign) and then perform a link to the Activity Party entity (where the party is the Contact). The following function shows this:


private static bool AlreadyResponded(string strCampaignId, string strCustomerId)
{
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "regardingobjectid";
condition.Operator = ConditionOperator.Equal;
condition.Values = new object[] { strCampaignId };
FilterExpression filter = new FilterExpression();
filter.Conditions = new ConditionExpression[] { condition };
filter.FilterOperator = LogicalOperator.And;
# region link to the Activity Party
entityLinkEntity link = new LinkEntity();
link.LinkFromEntityName = EntityName.activitypointer.ToString();
link.LinkToEntityName = EntityName.activityparty.ToString();
link.LinkFromAttributeName = "activityid";
link.LinkToAttributeName = "activityid";
ConditionExpression linkCondition = new ConditionExpression();
linkCondition.AttributeName = "partyid";
linkCondition.Operator = ConditionOperator.Equal;
linkCondition.Values = new object[] { strCustomerId };
FilterExpression linkFilter = new FilterExpression();
linkFilter.Conditions = new ConditionExpression[] { linkCondition };
linkFilter.FilterOperator = LogicalOperator.And;
link.LinkCriteria = linkFilter;
# endregion
QueryExpression query = new QueryExpression();
query.ColumnSet = new AllColumns();
query.Criteria = filter;
query.EntityName = EntityName.activitypointer.ToString();
query.LinkEntities = new LinkEntity[] { link };
BusinessEntityCollection collection = crm.RetrieveMultiple(query);
if (collection != null && collection.BusinessEntities.Length > 0)
return true;
return false;
}

Tagged: code


Источник: http://crmdude.wordpress.com/2009/08...rtylist-field/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crmdude: Whitepaper: The Microsoft Dynamics CRM Security Model Blog bot Dynamics CRM: Blogs 0 14.09.2009 11:05
crmdude: Emails disappear after installing CRM for Outlook Client Blog bot Dynamics CRM: Blogs 0 14.09.2009 11:05
crmdude: xRM Video on YouTube Blog bot Dynamics CRM: Blogs 0 14.09.2009 11:05
mscrm4ever: Summarizing an Appointment field on a Parent Entity Blog bot Dynamics CRM: Blogs 0 12.06.2009 15:05
axStart: table & field ID conflicts Blog bot DAX Blogs 0 29.05.2008 17:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 13:47.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.