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 :
Service | Customer Service, Contact Center, Fie...
Answered

Javascript code to show button when there is specific job type

(0) ShareShare
ReportReport
Posted on by 80

I'm not able to solve my problem please help me in that. Show button to form when job there is specific job type(lets take a typetype=abc but it is a lookup), i try enable rule in ribbon workbench. Can anyone help me to write a javascript code for that.

I have the same question (0)
  • Suggested answer
    Charan Raju C R Profile Picture
    7 Moderator on at

    1. Create a javascript library which contains below code to check the Job Type name and return boolean value based on the selected Job Type

    function enableButton(executionContext) {
        var isABCJobType = false;
        var jobType = executionContext.getAttribute("").getValue();
        isABCJobType = jobType != null && jobType[0].name.toLowerCase() == "abc";
        
        return isABCJobType;
    }

    2. Add enable rule (Custom Rule) in ribbon workbench, this calls custom javascript function enableButton. Also pass CRM Parameter 'Primary Control' to the javascript function. In my case below, I have created a javascript library called new_Account.js which contains a function enableButton.

    Enable Rule - Custom Rule:

    pastedimage1628756079642v2.png

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Parul,

    You want to hide one button based one field value, and the field is lookup field, right?

    Maybe you can use ‘ValueRule’ of Disply Rule to hide it directly without js code, which will be easier.

    pastedimage1628761915316v1.png

    Ribbon button visibility based on a field value in Dynamics 365 | Ribbon Workbench | D365 Demystified

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Parul Sharma Profile Picture
    80 on at

    not working

  • Community Member Profile Picture
    on at

    Hi Parul,

    Can you share some screenshots related to the lookup field and ribbon workbench?

    Regards,

    Leah Ju

  • Parul Sharma Profile Picture
    80 on at

    I'm not able to solve my problem please help me in that. Show button to form when job there is specific job type(lets take a typetype=abc but job type is a lookup), Can anyone help me to write a javascript code for that.

  • Verified answer
    mobeenmohsin Profile Picture
    on at

    Hi Parul,

    Please find the information below:

    https://balugajjala.wordpress.com/2017/01/27/enabledisable-a-ribbon-button-dynamically-based-on-a-form-value/

    If still not working, please raise support request with Microsoft at https://admin.powerplatform.microsoft.com/support.

    Best Regards,

    Mobeen Mohsin

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 55 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 27 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans