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

Опции темы Поиск в этой теме Опции просмотра
Старый 03.03.2018, 16:13   #1  
Blog bot is offline
Blog bot
21,332 / 725 (67) +++++++
Регистрация: 28.10.2006
CRMScape: MS CRM ActivityParty REST Queries

I recently had to create a rollup display showing all activities under a given entity. Pulling the sender or receiver out of an email activity requires a few steps.

Adding confusion the email entity has a text field ToRecipients which is an accumulated convenience text field. I would avoid using it as it is not complete if an email is sent to an email address that is not associated with a CRM contact, user etc. In this case the ToRecipients field will be null and the activity party AddressUsed field must be evaluated.

To fully reach the sender and receivers of email activities from an ActivityPointer query, the REST query needs to expand to include the activitypointer_activity_parties link table. You will need the ParticipationTypeMask to find out the role of each related activityparty, and both the AddressUsed and PartyId attributes.

Below is a sample query for all activities (ActivityPointer) related to an entity.
function retrieveActivities() { var caseId = AllCases[ProcessCaseIndex].Id; var parameters ="$select=ActivityId, RegardingObjectId, Subject, ActivityTypeCode, CreatedOn, ScheduledStart, Description, StateCode, OwnerId"; var expandParameters =",activitypointer_activity_parties/ParticipationTypeMask,activitypointer_activity_parties/PartyId,activitypointer_activity_parties/AddressUsed "; var expand ="&$expand=activitypointer_activity_parties"; var filter ="&$filter=RegardingObjectId/Id eq (guid'"+ caseId +"')"; var orderby ="&$orderby=CreatedOn"; var options = parameters + expandParameters + expand + orderby + filter; SDK.REST.retrieveMultipleRecords("ActivityPointer", options, retrieveActivitiesCallBack, function (error) { alert(error.message); }, activitiesRetrieveComplete);}

The ActivityPointer.ActivityTypeCode specifies the activity types:
  • email, appointment, phonecall, task, letter, fax, serviceappointment, campaignactivity, bulkoperation
  • caseresolution, opportunityclose, quoteclose, campaignresponse
The ParticipationTypeMask specifies the activity party role.
1 From, 2 To, 3 CC, 4 BCC, Owner 9, Regarding 8, and a number of others.

In the following code snipet we are just looking for the Sender or From activity party for email activities. The PartyId.Name is used if available otherwise it looks at the AddressUsed field, but this field is used in all the other email activity parties (From, To, CC, BCC).

<div class="wlWriterEditableSmartContent" contenteditable="false" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:eb73170f-1539-46b4-a46c-f2e93c4a4a88" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><div>function retrieveActivitiesCallBack(retrievedActivities) { for (var i =0; i <span style="color: black;">
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 13 Blog bot Dynamics CRM: Blogs 0 27.03.2013 22:12
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 12 Blog bot Dynamics CRM: Blogs 0 30.01.2013 01:11
crminthefield: CRM Upgrade Best Practices Blog bot Dynamics CRM: Blogs 0 11.10.2012 00:11
CRMScape: MS CRM and Portals (fast caching method) Blog bot Dynamics CRM: Blogs 0 04.08.2012 17:11
Leon's CRM Musings: Dynamics CRM Resources for the Rest Of Us Blog bot Dynamics CRM: Blogs 0 06.11.2010 03:11
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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