Skip to main content

Notifications

Service | Customer Service, Contact Center, Fie...
Answered

Get Interaction/Appointment Count against record

Posted on by 75


Hello,

I have a request to show an error message when a ribbon button is clicked.

This error message should only appear when there is less than 4 appointments/interactions against this record.

I am unsure on how to get this record count so I can conditionally show this error message.

Any ideas?

Thanks!

  • Jacooooob Profile Picture
    Jacooooob 75 on at
    RE: Get Interaction/Appointment Count against record

    Thanks that worked!!

  • Verified answer
    LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Get Interaction/Appointment Count against record

    Hi partner,

    It is possible to query the related appointments according to the current record form.

    We just need to get the current record id and use web api to query the related activities according to regording field.

    Here are the sample code for you.


    function getAppointmentCounts(executionContext){
        //get current record id
        var id = Xrm.Page.data.entity.getId();
        id=id.substring(1,id.length-1);
        var count=0;
        //get the related appointments' count.
        Xrm.WebApi.retrieveMultipleRecords("appointment""?$filter=_regardingobjectid_value eq '"+id+"'").then(
            function success(result) {
            count=result.entities.length;
            alert(count);

        })
    }

    Pay attention that the "Regarding" field should be used as "_regardingobjectid_value" when filter it in web api.

    1541.pastedimage1570155222200v1.png

    Hope it helps.

    Best Regards,

    Leo

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 Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

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... 290,912 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,355 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans