web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Create Phone Call Activity for Contact based on contact id using Dynamics Web API

(0) ShareShare
ReportReport
Posted on by

Hi,

Please suggest how to create a phone call activity for a contact based on contact id using Dynamics Web API in ASP.NET Web API.
By passing Entity collection as phone call entity can we create new activity?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Create Phone Call Activity for Contact based on contact id using Dynamics Web API

    Hi Goutam,

    I have already connected to Dynamics 365 in my custom application, in this I need to create phonecall activity based on the contact id and how do I find the user id only based on email id.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
  • Community Member Profile Picture
    on at
    RE: Create Phone Call Activity for Contact based on contact id using Dynamics Web API

    Hi Mike,

    Thanks for that link, I am a newbie to this using OrganizationService I was able to connect to CRM in ASP.NET Web API. We have integrated CTI to Dynamics 365 so based on the call I need to create phone activity for that ANI number using contactid. I want to implement this in ASP.NET web api.Please request you to suggest.

  • Community Member Profile Picture
    on at
    RE: Create Phone Call Activity for Contact based on contact id using Dynamics Web API

    Hi Goutam,

    Thanks for that link, I am a newbie to this using OrganizationService I was able to connect to CRM in ASP.NET Web API. We have integrated CTI to Dynamics 365 so based on the call I need to create phone activity for that ANI number using contactid. Please request you to suggest.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Create Phone Call Activity for Contact based on contact id using Dynamics Web API

    Hello Bindu ,

    You can refer below forum raised earlier . Hope this will definitely help you.

    community.dynamics.com/.../268185

  • Suggested answer
    Michel van den Brink Profile Picture
    4,697 on at
    RE: Create Phone Call Activity for Contact based on contact id using Dynamics Web API

    Hello,

    Take a look at this article for an example:

    acegcs.wordpress.com/.../creating-activities-using-web-api-in-dynamics-crm-2016

    This article unfortunately uses jQuery to do the actual AJAX call, so, I have taken the liberty of rewriting some of it into plain javascript.

    Phone calls have 3 special fields to track the customer, 'Regarding', 'From' and 'To'

    1. Regarding can be set to any record that allows activities
    2. From is an activity party and can contain one or more records
    3. To is an activity party and can contain one or more records

    Specifying activity parties can be done with the 'phonecall_activity_parties' property. Be sure to specify the appropriate 'participationtypemask' mask, to indicate which party the record belongs to.

    //create object
    var phoneCall = {
        "subject": "Phone Call",
        "phonenumber": "07685124677",
        "description": "My description",
        "directioncode": true, //Direction : 0-->False/Incomming, 1-->True/Outgoing
        "regardingobjectid_contact@odata.bind": "/contacts(475B158C-541C-E511-80D3-3863BB347BA8)", //Regarding is a contact
        "phonecall_activity_parties": [
            {
                "partyid_systemuser@odata.bind": "/systemusers(21102400-932F-E611-80E5-5065F38B2611)", // call started by a sustemuser
                "participationtypemask" : 1 // From
            },
            {
                "partyid_contact@odata.bind": "/contacts(59A0E5B9-88DF-E311-B8E5-6C3BE5A8B200)", // call to by a contact
                "participationtypemask": 2 // To
            }
        ]
    };
    
    //convert JSON object to string and send
    var jsonBody = JSON.stringify(phoneCall);
    
    var serverURL = Xrm.Page.context.getClientUrl();
    var req = new XMLHttpRequest();
    req.open("POST", encodeURI(serverURL + "/api/data/v8.2/phonecalls"), true);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.onload = function () {
        if (req.status >= 200 && req.status < 400) {
            // Success!
        } else {
            // We reached our target server, but it returned an error
    
        }
    };
    req.send(jsonBody); // send request to server


    Hope this helps you on your way :-)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans