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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get Row count from associated view using javascript

(0) ShareShare
ReportReport
Posted on by

Hi,

I'm trying to hide a button from the ribbon in an 'Associated View', and I tried to setup an enable rule depending on a javascript function. I want to hide the button if there are at least one row in the grid, or show it if there are no rows... I've searched a lot in forums and I can't seem to find an answer. Maybe there is an easy way to do this without javascript.

We are working with CRM 2015 online update 1, I hope someone has an idea on how can I make this work.

Thanks a lot in advance,

-JaimeN

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mahadeo Matre Profile Picture
    17,021 on at

    Hi,

    you can use similar code to get associated records

    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/SalesOrderSet?$select=Name&$filter=AccountId/Id eq (guid'')", false);
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function () {
        if (this.readyState === 4) {
            this.onreadystatechange = null;
            if (this.status === 200) {
                var returned = JSON.parse(this.responseText).d;
                var results = returned.results;
                if (results.length >= 1) {
                           return false;
                        }
                        else {
                            return true;
                        }
            }
            else {
                alert(this.statusText);
            }
        }
    };
    req.send();


    Here i am retrieving orders associated with account, by passing account id. 

    and when you get result return true or false to show or hide associated button. 

    Hope this will help.. 

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans