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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
Under review by Community Managers

Under review

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

Hide "New Request Form" button

Posted on by
In ribbon workbench I select entity acwapp_requestform where the subgrid is, and in that subgrid I want to hide the New Request Form button when the subgrid records has status of "Draft", "In Progress", or "Submitted", if the records has status of Rejected or Approved it will still show. Below is my whole code for javascript
function hideSubgridRibbonInRequest() {
    try {
        var formContext = Xrm.Page;
 
        var parentEntityName = formContext.data.entity.getEntityName().toLowerCase();
 
        console.log("Parent Entity Name:", parentEntityName);
 
        if (parentEntityName === "acwapp_lease") {
            var subgridControl = formContext.getControl("RequestForm");
 
            console.log("Subgrid Control:", subgridControl);
 
            if (subgridControl && subgridControl.getGrid()) {
                var gridRows = subgridControl.getGrid().getRows().get();
 
                console.log("Grid Rows:", gridRows);
 
                if (gridRows.length === 0) {
                    return true; // Show "New" button if there are no rows
                }
 
                var hideNewButton = true; // Assume initially we should hide the "New" button
 
                for (var i = 0; i < gridRows.getLength(); i++) {
                    var statusValue = gridRows.get(i).getData().getEntity().attributes.getByName("acwapp_status").getValue();
 
                    console.log("Status Value:", statusValue);
 
                    // Check if status is Draft, In Progress, or Submitted
                    if (statusValue === 557130000 || statusValue === 557130001 || statusValue === 557130002) {
                        hideNewButton = false; // Found an eligible status, show the "New" button
                        break; // No need to check further
                    }
                }
 
                return hideNewButton; // Return true to hide "New" button, false to show it
            }
        }
 
        return true; // Default behavior: hide "New" button
    } catch (error) {
        console.error("Error in hideSubgridRibbonInRequest:", error);
        throw error;
    }
}
Categories:

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans