Hot answers tagged

9

Yes, it's a known bug/limitation of Expression Operators. You can only evaluate two parameters in and and or expressions. You'll probably want to consider setting an attribute evaluated by your controller to determine the final logic behavior as a workaround.


6

Two things to add: 1) From a JavaScript perspective it makes sense. In JS extra parameters to a function are accepted and ignored. So and(true, true, false) returns true because it's a two-parameter function. 2) For what it's worth, you can chain any number of ANDs with && but unlike Visualforce you have to escape it to conform with XML rules. So {!...


5

object, the iteration variable for your <aura:iteration>, is not part of the v. value provider: <aura:if isTrue="{!v.object.Selected__c}"> You should have simply {! object.Selected__c } here. The expression you have never evaluates to true (because v.object doesn't exist), so your else branch always renders. It's often easier to use ...


5

The {! pair starts the expression (and } terminates the expression) rather than the ! character negating the expression. So use e.g.: <aura:if isTrue="{! notequals(ch.sumchans__StandalonePrice__c, 0) }"> or: <aura:if isTrue="{! !equals(ch.sumchans__StandalonePrice__c, 0) }">


5

The attribute value on the lightning:radioGroup is defined as an object. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_radioGroup.htm But that's because it's defined on the generic lightning:inputable interface. The lightning:radioGroup component writes it as an array, and it gets lockerized. Thanks to ...


5

It's an case sensitive issue, it should have been isTrue="{!v.showEditView}". Look at the aura:if. Always remember everything in Lightning component is case sensitive.


4

This is actually because "true" and "false" are rendering as String values, even though your attribute is a Boolean. I'm not sure why Lightning allows this, but the easiest fix is to use the true and false global providers: <lightning:menuItem label="Panal 1" value="{!true}" /> <lightning:menuItem label="Panal 2" value="{!false}"/> Or, ...


4

So, the specifications for aura:if explicitly state it needs an expression, however the attribute isTrue itself does say its a boolean. Given that, I would expect your syntax to work however it looks like it may be treating it is a truthy String. The easiest fix is to pass in an attribute like this: <aura:attribute name="myBool" type="Boolean" default="...


4

The benefit of aura:if is it does not even create the content inside its block if the conditions are false, thus it can help you make lightweight applications. Hiding a div via CSS will still create the block and thus I feel, it will be bad for performance. According to Salesforce docs Using the aura:if tag is the preferred approach to conditionally ...


4

In aura:if attribute, when you are using OR keyword, then it only evaluate first two condition as per this idea. You can convert or to || operator, and it will work fine. Try this - <aura:if isTrue="{! (v.radioOpValue == 'Daily' || v.radioOpValue == 'Weekly' || v.radioOpValue == 'Monthly')}">


3

Your problem is elsewhere in code you've omitted. Here's a self-contained example of comparing the current iterator to a specified value: <aura:application > <aura:attribute name="items" type="List" default="[1,2,3]" /> <aura:attribute name="current" type="Integer" default="2" /> <aura:iteration items="{!v.items}" var="item"...


3

I would think the simplest way to achieve is to just write 3 different aura:if blocks. Something as below? <aura:if isTrue="{!v.selectedVal == 'Phone'}"> .. do something .. </aura:if> <aura:if isTrue="{!v.selectedVal == 'Email'}"> .. do something .. </aura:if> <aura:if isTrue="{!v.selectedVal == 'None'}"> .. do ...


3

aura:if doesn't even create the components contained within unless isTrue is true. As such, you're really only creating one lightning:recordForm at a time as far as performance is concerned. You can expect nominal performance from this design, assuming there's not too many aura:if elements (they're pretty fast, but too many can be a performance concern), but ...


3

notequals(ofc.agentName, ' ') compares the value to a single space character, ' '. To check if the value is empty, use the empty() function: !empty(ofc.agentName) This will evaluate to true if the value is anything other than undefined, null, the empty array, and the empty string. (Note that it doesn't check for strings composed only of whitespace, though)....


3

Something like this would avoid invoking get on an undefined value: var input = component.find("assignedToInput1"); var assignedToId = input ? input.get('v.value') : null;


3

You have 3 options how to fix your code. They are sorted by the most preferred solutions. Refactor the component and move the logic into the helper and check only one boolean aura:attribute Use nasted expression functions and(and(v.userCountry != 'France', v.userCountry != 'Canada'), v.userCountry != 'Suisse')) Use corresponding logical operators v....


3

In your mainComponent, you dont really need displayHeaderDetails method because logically it is not doing anything - it is doing like if x is true then set x to true. Do below changes in another component: displayHeader: function(component, event, helper){ component.get("v.mianBody").set(v.hasHeader, true); }


2

Why don´t you add directly a boolean variable to your attribute? <aura:iteration items="{!v.layout}" var="item"> <aura:if isTrue="{!item.isHeader}">} Anyway the code your provided should work, I have some similar logic working in my org. An other comment I want to add is that you should not add an aura:if as an immediate child of aura:...


2

You could use a ternary operator in a condition expression in the class string and remove the <aura:if /> tags altogether. Documentation link: Lightning Conditional Expressions <aura:iteration items="{!v.activeApplicationsList}" var="actApp" indexVar="itemNum"> <li class="slds-item applicationTile {!actApp.status == 'In Review' ? '...


2

I suggest you print the value in {!v.account.cel_email_mailable__c} before your aura:if and see what it returning. See below. And also, I took the liberty of changing your condition slightly because it felt like you did not know how to use else in aura:if. <!-- Print the value in your component like so: --> cel_email_mailable__c = {!v.account....


2

Compiler is complaining because you're using assignment (=) instead of conditional operator (==), in second condition: (editMode='true'). Also AND function is case sensitive. Second problem mentioned by Jayant would give a problem at run time. You need to change: isTrue="{!AND(v._candidateDetails.contact.Nationalite__c != null), (editMode='true'))}" to: ...


2

You could load your scripts into just one component and call it using promises. Then you never need to worry about afterscriptsloaded or bad references. You'd have a component - say called "ScriptLoader". ScriptLoader would have these top level attributes: <aura:attribute name="yourscriptsource" type="String" default="{!$Resource.yourscriptname}"/> &...


2

Assuming that you are trying to use && and getting error, then that's expected. Using && is not allowed in components. You will need to use &amp;&amp; in that case. However, it is recommended that you use and(condition). This is from the documentation: &amp;&amp; This syntax is awkward in markup so we recommend using ...


2

What you have implemented is fine and should work. However, here are the checkpoints you can do: You should load this component in Opportunity Record page. You should implement error handling in callback to know what could be the problem: action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { ...


1

The name of the object member is sObjectType, not sobjecttype. See, for example, this Aura documentation: <aura:attribute name="newContact" type="Contact" default="{ 'sobjectType': 'Contact' }" /> However, depending on how you populate these records, you may not be able to rely upon its presence. For example, records returned from Apex server-...


1

No, doing this in the controller is the right way. There isn't a way to do regular expressions inside Lightning Expressions anyways, but even if you could, you'd still get better performance doing this in the controller/helper itself.


1

You can use if, else-if, else with nested elements: <aura:if isTrue="{!v.selected == 'None'}"> <aura:set attribute="else"> <aura:if isTrue="{!v.selected == 'Phone'}"> <lightning:input label="Phone" ... /> <aura:set attribute="else"> <lightning:input label="Email" ... /> </aura:set> ...


1

Try this:- <aura:attribute name="Text1" type="String"/> <aura:if isTrue="{!or(v.Text1=='Hello',v.Text1=='Bye')}"> <div> ABCD </div> </aura:if> It will work. What you were doing wrong is your T is small in isTrue as it is case sensitive and also Hello and bye should be in single quotes when you are ...


1

The problem is in the logic. Aura:if will render both sections with whatever cel_email_mailable__c not equals to N or Y. For example : cel_email_mailable__c == NULL cel_email_mailable__c == 'A'


1

Lightning is cAsE sEnSiTiVe. Check the capitalization of your field and attribute name. As an aside, it is far less error prone to simply say == Y and == N, rather than invert the nature of the tests. For example, if the value is == X, then both icons would also show. {!v.account.cel_email_mailable__c == 'Y'} and {!v.account.cel_email_mailable__c == 'N'}


Only top voted, non community-wiki answers of a minimum length are eligible