Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Hide subgrid buttons on a specific entity.

(0) ShareShare
ReportReport
Posted on by 277

Hi Experts, I want to hide a subgrid button depending upon current form field value and for specific entity. 

I tried some OOB rules and it's is working but the thing is: This subgrid is on different entities where the button needs to be visible, and the fields I'm trying to use have same schema name.

Is there a specific OOB rule to check for entity type? Thanks in advance

*This post is locked for comments

  • Turbo Forms Profile Picture
    277 on at
    RE: Hide subgrid buttons on a specific entity.

    Hi Pravin, Thanks for the reply. I tried the below code but it's still not working. ANy idea? 

    function HideButtonsAfterRouted(primaryControl) {
        formContext = primaryControl;
        debugger;
        var routed = formContext.getAttribute("new_routed").getValue;
        var initApproved = formContext.getAttribute("new_initiatorapproved").getValue;
        var recordType = formContext.getAttribute("new_recordtype").getValue;
    
        var entityname = formContext.data.entity.getEntityName();
    
        if (entityname == "new_request" && (recordType == 800000010 || recordType == 800000011)) {
    
            if (routed == 1)
                return false
            else
                return true;
        }
        else if (entityname == "new_request" && (recordType == 800000029 || recordType == 800000030 || recordType == 800000031 || recordType == 800000032)) {
    
            if (initApproved == 1)
                return false
            else
                return true;
        }
    }


    4251.Capture.PNG

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at
    RE: Hide subgrid buttons on a specific entity.

    Hi ,

    You can use following logic inside js:

    var variablename = Xrm.Page.getAttribute("fieldlogicalname");

    var entityname = Xrm.Page.data.entity.getEntityName();

    if (variablename != null && entityname== "expectedlogicalname")

    {

    var variablevalue = variablename.getValue();

    if (variablevalue != null)

    return false

    else

    return true;

    }

    Call this function code on button using ribbon action.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans