I have created a Lightning Component that will update a custom field whenever a button is clicked.

I want the button to be hidden when {!Go\_No\_Go\_Question\_\_c} is blank.

Right now, the button is disabling but it is disabling when the {!Go\_No\_Go\_Question\_\_c} has a value.

See code below

**APEX:**

```
public class addGNGQuestion {

    @AuraEnabled
    public static void updateChk(String key){
        Opportunity acc = [SELECT Id, Name, Submit_Go_No_Go_Question__c, Go_No_Go_Question__c FROM Opportunity WHERE Id=:key];  
        if(acc.Go_No_Go_Question__c == null){
            acc.Submit_Go_No_Go_Question__c = true;
        }
        UPDATE acc;
    }

    @AuraEnabled
    public static boolean getOppty(String key){
        Opportunity acc = [SELECT Id, Name, Submit_Go_No_Go_Question__c, Go_No_Go_Question__c FROM Opportunity WHERE Id=:key];  
        if(acc.Go_No_Go_Question__c!=null){
        return true;
        }else{
        return false;
        }
    }
}

```

**Component**

```
<aura:component controller="addGNGQuestion"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

     <aura:attribute name="opp" type="boolean"/>
     <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
    <div class="slds-align_absolute-center" style="height:12rem">
    <lightning:button variant="brand" 
                      label="Add Go-No Go Question" 
                      onclick="{!c.updateCheck}" 
                       aura:id="disablebuttonid" disabled="{!v.opp}"/> 
        </div>
</aura:component>

```

**Controller**

```
({

     doInit : function(component, event) {
         var action = component.get("c.getOppty");
                 action.setParams({ key :component.get("v.recordId") });

         action.setCallback(this, function(a) {
             component.set("v.opp", a.getReturnValue());
         });
         $A.enqueueAction(action);
     },

    updateCheck : function(component, event, helper) {
        var rid = component.get("v.recordId");
        var action = component.get("c.updateChk");
        action.setParams({key : rid});
        action.setCallback(this, function(response) {
            var state = response.getState();

            if (state === "SUCCESS") {
                component.set("v.opp",true );
                $A.get('e.force:refreshView').fire();  
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } 
                else {
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },

    isRefreshed: function(component, event, helper) {
        location.reload();
    },
})

```

Also, I understand that there is no *Hidden* attribute as per this [link](https://developer.salesforce.com/docs/component-library/bundle/lightning:button/specification), so for the meantime I used the Disabled attribute. I would like to know if there is a workaround for this? Also I want the button to be disabled/hidden when !Go\_No\_Go\_Question\_\_c} is blank.

Any help is much appreciated

**Update**

Component

```
<aura:component controller="addGNGQuestion"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

     <aura:attribute name="opp" type="boolean"/>
     <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
    <aura:if isTrue="{!v.opp}">
    <div class="slds-align_absolute-center" style="height:12rem">
    <lightning:button variant="brand" 
                      label="Add Go-No Go Question" 
                      onclick="{!c.updateCheck}" 
                      aura:id="disablebuttonid"  disabled="{!v.opp}"/>
        </div>
        </aura:if>
</aura:component>

```

Apex: 

```
public class addGNGQuestion {

    @AuraEnabled
    public static void updateChk(String key){
        Opportunity acc = [SELECT Id, Name, Submit_Go_No_Go_Question__c, Go_No_Go_Question__c FROM Opportunity WHERE Id=:key];  
        if(acc.Go_No_Go_Question__c == null){
            acc.Submit_Go_No_Go_Question__c = true;
        }
        UPDATE acc;
    }

    @AuraEnabled
    public static boolean getOppty(String key){
        Opportunity acc = [SELECT Id, Name, Submit_Go_No_Go_Question__c, Go_No_Go_Question__c FROM Opportunity WHERE Id=:key];  
    if(acc.Go_No_Go_Question__c == ''||acc.Go_No_Go_Question__c == null){
    return true;
    }else{
    return false;
    }
}

```

The result is, without a record or Go\_No\_Go\_Question\_\_c being blank, the button is showing but it is disabled.
[![enter image description here](https://i.stack.imgur.com/bQUqO.png)](https://i.stack.imgur.com/bQUqO.png)

With a record, the button is missing.
[![enter image description here](https://i.stack.imgur.com/zVoJo.png)](https://i.stack.imgur.com/zVoJo.png)

My goal is when Go\_No\_Go\_Question\_\_c has a value, the button is missing. When Go\_No\_Go\_Question\_\_c is blank the button will be Enabled and visible.