Answered by:
Change the ribbon button text (CRM 2011 online)

Question
-
Hi All,
I have created a custom button on the Quote entity ribbon area. Depending upon some condition in script I am changing the button text.
Using a javascript function in Quote entity page load to change the button text. When the page is loading it showing the modified text.
But after some time again it is changing to the previous text.
I have keep the debugger in the page load javascript function , first time the script is firing. But when the button text is changing to the previous text it not going to the page load.
Please helps me how to fix it?
Regards,
Priya
Friday, December 21, 2012 2:41 PM
Answers
-
Hi Priya,
Changing the label using Javascript is not supported which is why you see the label going back to the previous value.
You need to add Ribbon Customisations to do this which can be done by editing RibbonXml or you can use the Ribbon Workbench: http://ribbonworkbench.uservoice.com/knowledgebase/articles/71374-1-getting-started-with-the-ribbon-workbench
There is no way of dynamically changing the label in a supported way - you can enable/disable buttons dynamically, or use a flyout anchor to create the buttons on the fly : http://www.develop1.net/public/post/Add-Dynamic-Menu-to-Ribbon-Button.aspx
Scott
Scott Durow
Read my blog: www.develop1.net/publicFollow Me on Twitter
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"- Edited by Scott Durow (MVP)MVP, Editor Friday, December 21, 2012 2:51 PM
- Marked as answer by PriyaSwain Saturday, December 22, 2012 1:13 PM
Friday, December 21, 2012 2:50 PMAnswerer
All replies
-
Hi Priya,
Changing the label using Javascript is not supported which is why you see the label going back to the previous value.
You need to add Ribbon Customisations to do this which can be done by editing RibbonXml or you can use the Ribbon Workbench: http://ribbonworkbench.uservoice.com/knowledgebase/articles/71374-1-getting-started-with-the-ribbon-workbench
There is no way of dynamically changing the label in a supported way - you can enable/disable buttons dynamically, or use a flyout anchor to create the buttons on the fly : http://www.develop1.net/public/post/Add-Dynamic-Menu-to-Ribbon-Button.aspx
Scott
Scott Durow
Read my blog: www.develop1.net/publicFollow Me on Twitter
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"- Edited by Scott Durow (MVP)MVP, Editor Friday, December 21, 2012 2:51 PM
- Marked as answer by PriyaSwain Saturday, December 22, 2012 1:13 PM
Friday, December 21, 2012 2:50 PMAnswerer -
Hi Scott,
Thanks a lot for your valuable time.
I have created two buttons on ribbon. Depending upon my condition showing and hiding the buttons in javascript .
Regards,
Priya.
Saturday, December 22, 2012 1:16 PM -
Hello Scott,
Using javascript in form onload I am hiding and showing the custom ribbon button.
It is working fine. But when I am updating any field, script is firing but style is not applying.
So it is displaying all the buttons.
Below the script I am using.
function renameCreateContract() { var contractGuid = Xrm.Page.getAttribute("new_contract").getValue(); //Getting the Create contract button ID var createContractBtn = top.document.getElementById("quote|NoRelationship|Form|MyOrg.Form.quote.MainTab.MyOrgQuote.CreateContract-Large"); //Getting the Update contract button ID var updateContractBtn = top.document.getElementById("quote|NoRelationship|Form|MyOrg.Form.quote.MainTab.MyOrgQuote.UpdateContract-Large"); //If the contract look field contains data if (contractGuid != null) { updateContractBtn.style.display = ''; createContractBtn.style.display = 'none'; } else { createContractBtn.style.display = ''; updateContractBtn.style.display = 'none'; } }
I am doing anythig wrong?
Regards,
Priya.
Monday, December 31, 2012 5:42 AM -
Hi,
Instead of using JScript to hide/show ribbon buttons, better approach and supported way is to use DisplayRule. For your requirement, you can use DisplayRule with ValueRule. You can check following posts to see how you can achieve it.
http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/3d33d9b1-ff7c-4382-b022-4fcbbed0f434
http://howto-mscrm.blogspot.sg/2011/04/how-to-series-5-how-to-use-valuerule.html
http://sumedha8.blogspot.sg/2011/11/defining-displayrule-for-buttons.htmlVikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
- Proposed as answer by Vikranth Pandiri Monday, December 31, 2012 7:06 AM
Monday, December 31, 2012 7:06 AM -
Hi Vicky,
Thanks for your replay.
The above links are using the static value for value rules.
Can you please provide some information for dynamic value rules?
- Edited by PriyaSwain Wednesday, January 2, 2013 6:33 AM
Wednesday, January 2, 2013 6:33 AM -
Hi Priya,
Unfortunately, you can only use Custom Javascript rules with enable/disable rules. You could try using JavaScript to set a value on the form and then refreshing the ribbon with a value rule.
Scott
Scott Durow
Read my blog: www.develop1.net/publicFollow Me on Twitter
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"Wednesday, January 2, 2013 7:21 AMAnswerer