Answered by:
Disable a custom ribbon button based on a form value

Question
-
I have put custom button named "Generate PO" in menu bar in sales order entity...
Now,I want to check if order status is "Active" then only this menu is visible..otherwise menu isnot visible
How can I achieve this?
- Edited by NikkiShah Monday, September 14, 2015 5:35 AM
Saturday, September 12, 2015 11:05 AM
Answers
-
Hi,
Please ensure that your changes gets published.
You can also try EnableRule to disable/enable the button based on the Status value.
Use CustomRule to call a custom Javascript function (DisablePObutton) like this.
function DisablePOButton() { if (Xrm.Page.getAttribute('statuscode') == "1") return true; else return false; }
Hope it helps. Refer this.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
- Marked as answer by NikkiShah Tuesday, September 15, 2015 8:08 AM
Tuesday, September 15, 2015 5:23 AM
All replies
-
Hi Shah,
yiu can use ribbon "Value Rule" for order (statuscode = 1 : New) to check the value of the order Status if one Display your button otherwise hide it.
Use Ribbon Workbench tool to apply this.
http://stackoverflow.com/questions/23674584/ribbon-button-value-rule-depending-on-statecode-value
https://ribbonworkbench.uservoice.com/knowledgebase/articles/121427-enable-disable-a-ribbon-button-dynamically-based-o
hope this helps.
Thanks
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
Sunday, September 13, 2015 9:47 AM -
I have tries to apply value rule as i shows in below image
In this case ,"Generate PO" button is visible each time
Please Correct me if i missed something?
Monday, September 14, 2015 5:52 AM -
Hi NikkiShah,
Try to set InverResult to true and check your condition.
Mahender
- Edited by HIMBAPModerator Monday, September 14, 2015 6:11 AM
Monday, September 14, 2015 6:11 AMModerator -
thank you himbap for your reply,
It is complulsary to set InverResult field?
Without it my condition is right-
I want to display my custom button when status code is "0:Active" only.
please correct me if i am going wrong?
- Edited by NikkiShah Monday, September 14, 2015 6:17 AM
Monday, September 14, 2015 6:14 AM -
Just like while writing any condition, if you have to write if and else, to execute alternate operation in case first is not true , so here you have if part but you are missing else part, as you said your button is always available, so to hide it in case status is not active you need to set invertResult.
Mahender
- Edited by HIMBAPModerator Monday, September 14, 2015 6:22 AM
Monday, September 14, 2015 6:22 AMModerator -
As you suggest I have added invertResult property
In this button appears in each case
Please correct me
- Edited by NikkiShah Monday, September 14, 2015 7:32 AM
Monday, September 14, 2015 6:36 AM -
Did you try to set true as I said in my earlier response ??
Mahender
- Edited by HIMBAPModerator Tuesday, September 15, 2015 7:21 AM
Monday, September 14, 2015 7:53 AMModerator -
Yes..i tries all this conditions below-
1.)default-true
invertResult-false----------button disappers
2.)default-false
invertResult-true----------button appers
3.)default-true
invertResult-null----------button disappers
4.)default-null
invertResult-true----------button disappers
5.)default-null
invertResult-null----------button disappersAccording to my observation,I guess whatever we set in invertResult ,The output comes.
If we set invertResult to true--button appears in each case
If we set invertResult to false--button disappears in each case
Why this happens?
Monday, September 14, 2015 7:59 AM -
Hi,
Can you update the field to "statuscode" and check again.
regards,
Yusuf
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
Monday, September 14, 2015 8:52 AM -
tried as u suggest.but didnot work
But button appears every time
- Edited by NikkiShah Monday, September 14, 2015 9:01 AM
Monday, September 14, 2015 9:01 AM -
Hi,
try this
Default Value : Null
InvertResult : True
Hope it helps,
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
Monday, September 14, 2015 10:12 AM -
I tried that also it still appears...Monday, September 14, 2015 10:25 AM
-
Hi,
Please ensure that your changes gets published.
You can also try EnableRule to disable/enable the button based on the Status value.
Use CustomRule to call a custom Javascript function (DisablePObutton) like this.
function DisablePOButton() { if (Xrm.Page.getAttribute('statuscode') == "1") return true; else return false; }
Hope it helps. Refer this.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
- Marked as answer by NikkiShah Tuesday, September 15, 2015 8:08 AM
Tuesday, September 15, 2015 5:23 AM