Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Hide subgrid buttons on a specific entity.

Posted on by 275

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
    Turbo Forms 275 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
    Pawar Pravin 5,227 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans