You need to sign in to do that
Don't have an account?
Hermann Ouré
aura component duplicate value
Hello,
I have an aura component to show / hide field depending on checkbox values. What I'm trying to do is to when the checkbox for the current user is checked, to show the field on the component. But if the current user profile name is different from the record owner, to make the field on the component disabled.
The problem is that 2 fields on my component is showing when I only want to display one.
How do I change my markup to apply the logic on the same lightning textarea so only 1 is shown
I have an aura component to show / hide field depending on checkbox values. What I'm trying to do is to when the checkbox for the current user is checked, to show the field on the component. But if the current user profile name is different from the record owner, to make the field on the component disabled.
The problem is that 2 fields on my component is showing when I only want to display one.
How do I change my markup to apply the logic on the same lightning textarea so only 1 is shown
<aura:component controller="ActionDescriptionFieldShowHideController" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" > <aura:attribute name="recordId" type="String"/> <aura:attribute name="actionRec" type="Action__c" default="{'sObjectType':'Action__c'}"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <lightning:spinner alternativeText="Loading" size="large" aura:id="spinner" class="slds-hide" /> <aura:attribute name="CurrentUser" type="Object"/> <force:recordData recordId="{!$SObjectType.CurrentUser.Id}" fields="Profile.Name" targetFields="{!v.CurrentUser}"/> <form class="slds-form_stacked"> <aura:if isTrue="{!and(v.actionRec.Commercial__c == true, v.CurrentUser.Profile.Name == 'Sales')}"> <lightning:textarea label="Description" name="desc" value="{!v.actionRec.Description__c }"/> <aura:set attribute="else"> <aura:if isTrue="{!and(v.actionRec.Commercial__c == true, v.CurrentUser.Profile.Name != 'Sales')}"> <lightning:textarea label="Description" name="desc" disabled="true" value="{!v.actionRec.Description__c }"/> </aura:if> </aura:set> </aura:if> <footer class="slds-modal__footer"> <lightning:button variant="brand" label="Save" title="Save" onclick="{! c.actionSave}" /> </footer> </form> </aura:component>
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Thanks for your reply.
I have tried the code you provided but it's still showing 2 fields.
Try this
Hope this helps!
Can you please debug value in your component.
Commercial==>>>>> {!v.actionRec.Commercial__c}
Profile.Name ==>>>> {!v.CurrentUser.Profile.Name}
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Hello Mukesh,
Not sure how to put debug log in aura
Also I tried to update my component in the following manner
But still showing the lightning:textarea twice
if anyone knows how to implement it. that would be very much appreciated
so would become something like
The only issue now is that as soon as I enter a value, the <lightning:textarea/> becomes disabled
The issue either comes from my function or from the
here is how I have updated my cmp
then I needed to create a function on the controller.js
and the apex for the recordOwnerProfileName