function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TrudgeTrudge 

Conditionally hide or disable quick action in Lightning.

Hello,

I'm going through the process of building Lightning alternatives to all of our JavaScript buttons from Classic.  I'm creating a quick action with prepopulated values to replace a JS button that did the same.  The issue I'm running into is that the JS button also included an if/else alert that required the object to have a specific Status for the button to work.

Is there a way to either hide or disable a quick action based on the value of a Status field?  

Thanks for any help in advance!

-Chad
NagendraNagendra (Salesforce Developers) 
Hi Trudge,

Please try with below steps and let us know if it works.

First step, create ui:button
<ui:button label="test" press="{!c.doAction}" aura:id="myButton"/>
Next step, add to controller
({ doAction : function(component, event, helper) { var button = component.find("myButton"); $A.util.addClass(button.getElement(), 'invisible'); ... code }, })
And you can add new class in STYLE
.THIS .uiButton.invisible { display: none; }
Related Salesforce Documentation: Adding and Removing Styles (during runtime)- Please let us know if this was helpful.

Kindly mark this as solved if it's resolved.

Thanks,
Nagendra