0

i am want to use dynamic changing of the button. I am using aura:if but i dont know how to pass custom field value into it, or if it is even possible.

                <aura:if isTrue="{!customField__c == 0}">
                    <lightning:buttonIcon iconName="utility:copy"  onclick="{!c.copyOrDelete}" />
                    <aura:set attribute="else">
                        <lightning:buttonIcon iconName="utility:copy"  onclick="{!c.copyOrDelete}" />
                    </aura:set>
                </aura:if>

I am using checkbox custom field to get boolean as i need to, in the custom object.

Thanks for any help.

2
  • you can pass aura attribute into isTrue expression. How do you define this customField__c in your component code? Aug 28, 2018 at 6:32
  • I dont. I dont know how to do it. Its something with <aura:attribute />?
    – David
    Aug 28, 2018 at 7:18

1 Answer 1

1

How are you getting customField__c? Assuming you have something in lines of:

<aura:attribute name="record" type="SObject"/>

in your markup and you are setting a value to that record attribute from your ControllerJS like so:

component.set("v.record", response.getReturnValue()); //assuming a server-side action here that returns customField__c in its query 

then you can do something like:

<aura:if isTrue="{!v.record.customField__c == 0}">
                    <lightning:buttonIcon iconName="utility:copy"  onclick="{!c.copyOrDelete}" />
                    <aura:set attribute="else">
                        <lightning:buttonIcon iconName="utility:copy"  onclick="{!c.copyOrDelete}" />
                    </aura:set>
                </aura:if>

Notice the {!v.record.customField__c == 0} syntax. The 'value provider', identified by {!v.XXX} is required at all times when referring to an attribute.

So in short, you are missing the value provider in your condition:

{!customField__c == 0}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .