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 :
Dynamics 365 general forum

Hide and Show button in Ribbon based on Form Field Value

(0) ShareShare
ReportReport
Posted on by 134

Hello,

I want to hide /show custom button according to entity field value (data type:- option set value). If field value is "A" then it show button otherwise hide that button .

 2019_2D00_05_2D00_23.png

function HideButton() {

var fieldVaue = Xrm.Page.getAttribute("new_multipalvalue").getText();
if (fieldVaue == Item1) {
return true;
}
else {
return false;
}
}

but it not working so how could i solve this problems. 

I have the same question (0)
  • Suggested answer
    T.I.A Profile Picture
    1,760 on at

    Have you tried getting the option set value instead?

    It may not be best practice to use the optionset text over the optionset value. If you change that optionsets value text in the future you will need to amend all script where it is being called.

  • Suggested answer
    Srikanta Mahapatro Profile Picture
    190 on at

    Hi ,

    You have to add Enable rule with value rule. Please go through the below link. you might get an idea.

    garethtuckercrm.com/.../dynamically-disable-ribbon-buttons-in-dynamics-crm

    ribbonworkbench.uservoice.com/.../121427-enable-disable-a-ribbon-button-dynamically-based-o

    https://community.dynamics.com/.../275236

     

    Thanks,
    Srikanta

    If found useful, please mark the answer as verified.

     

  • Kokulan Profile Picture
    18,054 on at

    Could you share the screenshot of enable rule?

  • Srikanta Mahapatro Profile Picture
    190 on at

    The screenshots can be found in garethtuckercrm.com/.../dynamically-disable-ribbon-buttons-in-dynamics-crm

  • Suggested answer
    Antonio Lamanna Profile Picture
    165 on at

    Try to use value instead of text and check if the field is not null before use getValue(), then set the call to this function in an Enable Rule:

    function HideButton() {
    var fieldVaue = Xrm.Page.getAttribute("new_multipalvalue");

    if (fieldVaue != null) {
    var showbutton = fieldVaue.getValue() == 100000001;
    return showbutton;
    }
    }
    
    


    if (fieldVaue! = null) {o;

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 Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Dynamics 365 general

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans