Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

How to get 'Call From' and 'Call To' of all phone call in WEB API

Posted on by 30

In OrganizationService, I can easily get the 'Call From' and 'Call To' of phone call by using columns 'From' and 'To' , either thought fetch XML, or using RetrieveEntityRequest, it's quite straight forward.

but in Dynamics 365 WEB API, these two columns not returned, need using $expand or link-entities in fetch xml, is there any other ways to get these two columns ?

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: How to get 'Call From' and 'Call To' of all phone call in WEB API

    Hi Flex Xuan,

    Please kindly let me know whether it could work for you. Thanks.

    Regards,

    Clofly

  • Suggested answer
    cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: How to get 'Call From' and 'Call To' of all phone call in WEB API

    Hi Flex Xuan,

    'Call From' and 'Call To' are party list type field, they will be saved as separate activityparty entity records.

    In other word, there will be two activityparty records for a phone call record. 

    We should instead expand activityid_phonecall property to show fields of related phone call record.

    e.g:

    display 'Call From' and 'Call To' field of a specific phone call record:

    var entityId = 'xxxx'; // phone call record id
    Xrm.WebApi.retrieveMultipleRecords("activityparty", "?$expand=activityid_phonecall($select=subject)&$filter=_activityid_value eq "   entityId 
                  " and (participationtypemask eq 1 or participationtypemask eq 2)&$select=_partyid_value,_activityid_value,participationtypemask").then(
        function success(result) {
            for (var item in result.entities) {
                if (result.entities[item]["participationtypemask"] === 1) {
                    console.log("Phone call activity: "   result.entities[item]["_activityid_value"]   ", Subject: "   result.entities[item]["activityid_phonecall"]["subject"]   ", Call From: "   result.entities[item]["_partyid_value@OData.Community.Display.V1.FormattedValue"]);
                } else if (result.entities[item]["participationtypemask"] === 2) {
                    console.log("Phone call activity: "   result.entities[item]["_activityid_value"]   ", Subject: "   result.entities[item]["activityid_phonecall"]["subject"]   ", Call To: "   result.entities[item]["_partyid_value@OData.Community.Display.V1.FormattedValue"]);
                }
            }
        },
        function (error) {
            console.log(error.message);
        }
    );

    pastedimage1587457342646v1.png

    If activity entity is "PhoneCall", then when participationtypemask field of activityparty record equals to 1, it stands for Call From,

    when the field equals to 2, it stands for Call To.

    In a word, we should retrieve phone call based on activityparty entity.

    Furthermore, we can also retrieve "From" and "To" fields of Email based on it.

    Here are some helpful links about your question:

    1. participationtypemask code meaning for different activity entities:

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/activityparty-entity

    2. available properties to expand of activityparty entity:

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/activityparty?view=dynamics-ce-odata-9#single-valued-navigation-properties

    3. a tutorial about the topic:

    https://promx.net/en/2020/01/how-to-retrieve-an-activity-party-list-in-microsoft-dynamics-365-using-web-api/

    Regards,

    Clofly

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,104 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans