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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Not able to change label of ribbon button through javascript

(0) ShareShare
ReportReport
Posted on by 264

Hello experts,

I have a custom button over ribbon bar for status management of user. I could change the status of user by clicking over it however could not change the label of button.

pastedimage1579026639841v1.png

I want to change the label from offline or available based on the status of use. I tried to set the control with PrimaryControl,SelectedControl,etc to function parameter in javascript, but control parameter shows undefined while calling the function on click.Also i could not get the element by its id in function ($('#crmRibbonManager ul li').each()) to get the control but nothing worked. Any help is much appreciated.

Thanks and regards,

Drashti Mehta

I have the same question (0)
  • Johao Larios Profile Picture
    1,795 on at
    RE: Not able to change label of ribbon button through javascript

    Hello Drashti, make modifications directly in the HTML is not supported, please refer to:

    docs.microsoft.com/.../supported-extensions

    To modify the ribbon, you should modify the customizations.xml file of a solution .zip as mentioned here docs.microsoft.com/.../export-prepare-edit-import-ribbon or use a third party application such as ribbon workbench.  ribbonworkbench.uservoice.com/.../71374-1-getting-started-with-the-ribbon-workbench

  • Suggested answer
    PS Profile Picture
    23,577 on at
    RE: Not able to change label of ribbon button through javascript

    Hi Drashti

    With the help of ribbon workbench you can duplicate the button then change names as you want and then apply rules to show hide based on your requirement.

    That's supported customisation. Download it here: www.develop1.net/.../ribbonworkbench.aspx

    Learn about it more here: ribbonworkbench.uservoice.com/.../71374-1-getting-started-with-the-ribbon-workbench

  • Suggested answer
    AJ-22040756-0 Profile Picture
    on at
    RE: Not able to change label of ribbon button through javascript

    Hi Partner, 

    You can use ribbon workbench to show/Hide the buttons based on form value, you can refer this article for the same community.dynamics.com/.../771312 

  • Drashti Mehta Profile Picture
    264 on at
    RE: Not able to change label of ribbon button through javascript

    Thanks for the reply, but i need to change label after changing the status for which i am using XMLHttpRequest. How could i manage to use enable disable rule in success of the request?

    Thanks and regards,

    Drashti Mehta

  • Verified answer
    cloflyMao Profile Picture
    25,210 on at
    RE: Not able to change label of ribbon button through javascript

    Hi Drashti,

    Try to get the button and change its label by following code.

    parent.document.getElementById("cr251.ApplicationRibbon.customButton.button1").children[0].children[0].children[1].innerText = 'Button 1100';

    pastedimage1579075023552v1.png

    You can get the parent li element's ID as entrance. 

    pastedimage1579075113649v2.png

    The label has been changed to "button 1100".

    pastedimage1579075189561v3.png

    Regards,

    Clofly

  • Drashti Mehta Profile Picture
    264 on at
    RE: Not able to change label of ribbon button through javascript

    Thanks Clofy, this worked like a charm but a small question can we call the same function on logging into CRM?

    Thanks and regards,

    Drashti Mehta

  • Drashti Mehta Profile Picture
    264 on at
    RE: Not able to change label of ribbon button through javascript

    Also can anyone suggest a way to set enable disable rule on success of XMLHttpRequest ?

  • cloflyMao Profile Picture
    25,210 on at
    RE: Not able to change label of ribbon button through javascript

    Hi Drashti,

    -> can we call the same function on logging into CRM?

    Would it mean that the function could be executed on home page?

    If so, you could take following method as reference:

    1. Create a HTML web resource on homepage(actually dashboard, mine default is Sales Activity Dashboard)

    and embbed a script on the page with timer, it could be regarded as a script web resource at form onLoad event.(because we couldn't run script directly on dashboard)

    
    
    
      
      Page Title
    
    
    
    
    
      
    
    
    

    2. Hide the page.

    pastedimage1579080407614v1.png

    3. Publish customization

    pastedimage1579080454328v2.png

    result

    pastedimage1579080475486v3.png

    -> a way to set enable disable rule on success of XMLHttpRequest

    As far as I know, we could only apply display rule in ribbon workbench, I don't know whether there was javascript API to hide ribbon button directly.

    (But my thought is that there was no such API, we could only hide it with javascript getElement directly)

    Regards,

    Clofly

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 258

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 179

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 128 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans