Skip to main content

Notifications

Dynamics 365 general forum

How to get all the Lead activities of particular contact in MS Dynamics CRM 365, v9.0?

Posted on by Microsoft Employee

Hi,

I want to get all the activities of Leads based on contact assign to lead as a customer. For example there is a contact "Nanji Mange". I have assign this contact as a customer in different 30 leads. Each lead has 4 activities. So there will be total 120 activities. Now, on the based of the contact, I want to get list of activities.

I want to get this using API using javascript ajax call. I have following way but it will make it too slow.

1- Fire a query to get all the leads whose customer is "Nanji Mange"

2- Loop of result get in #1(30 records)

3- In each loop, fire a query on activity whose "Regarding" value is current lead id. 

Note: Above solution works but as loop iterates for 30 times and it takes too much time. This is example of 30. There can be 100-1000 leads.

Can anybody please suggest me faster way to get this?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get all the Lead activities of particular contact in MS Dynamics CRM 365, v9.0?

    Hi

    Yeah Ravi, it working the way you suggested.

    I have asked separate question which is extended to this question community.dynamics.com/.../297068

    Please suggest.

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: How to get all the Lead activities of particular contact in MS Dynamics CRM 365, v9.0?

    Hi,

    You don't need to do all this, build a fetch xml query which returns the activities where regarding (Lead)'s Customer is your contact (i.e. your contact). For this, you can use advance find. Once the query is ready, you can use WEB API to run the fetchxml directly.

    Refer these links-

    community.dynamics.com/.../using-fetchxml-with-xrm-webapi-retrievemultiplerecords-in-dynamics-365-v9

    docs.microsoft.com/.../retrieve-and-execute-predefined-queries

    You can use CRM Rest Builder to build the WEB API request. This is the easiest way to build the query as well as execute it and see the results.

    carldesouza.com/dynamics-crm-rest-builder

    You can download the tool here- github.com/.../releases

    Hope this helps.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

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,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans