How to evaluate multiple conditions in aura:if else condition on Lightning Component Salesforce | How to check multiple conditions using conditional AND/OR Operators in aura:if attribute in Salesforce Lightning Component

Vijayk
3 min readApr 25, 2022

Hey guys, today in this post we are going to learn about How to check multiple conditions using conditional AND/OR Operators in aura:if attribute in Salesforce Lightning Component Salesforce.

aura:if evaluates the isTrue expression on the server and instantiates components in either its body or else attribute. Only one branch is created and rendered.

This component allows you to conditionally render its contents. It renders its body only if isTrue evaluates to true. The else attribute allows you to render an alternative when isTrue evaluates to false.

The expression in isTrue is re-evaluated every time any value used in the expression changes. When the results of the expression change, it triggers a re-rendering of the component. Use aura:renderIf if you expect to show the components for both the true and false states, and it would require a server round trip to instantiate the components that aren’t initially rendered. To know more details about aura:if attribute, Click Here..

Files we used to check multiple conditions in Lightning Component →

AuraIfMultipleConditionCmp.cmp

Lightning Component

It is used to check multiple conditions AND/OR Operators in aura:if attribute in lightning component

AuraIfMultipleConditionCmpApp.app

Lightning Application

It is used for call the component to preview on browser.

Final Output → To get source code live demo..

Other related post that would you like to learn in LWC

Create Lightning Component

Step 1:- Create Lightning Component : AuraIfMultipleConditionCmp

From Developer Console >> File >> New >> Lightning Component

AuraIfMultipleConditionCmp [Lightning Component File]

Create Lightning Application

Step 2:- Create Lightning Application : AuraIfMultipleConditionCmpApp.app

From Developer Console >> File >> New >> Lightning Application

AuraIfMultipleConditionCmpApp.app [Component Application File]

Further post that would you like to learn in LWC FAQ (Frequently Asked Questions)

How do you use multiple conditions in aura?

In the aura:If tag multiple conditions can’t be evaluated using logical operator like ‘&&,||,and,or’. For evaluating multiple conditions in the aura:if tag we are required to use logical function or(), and(). nested condition div show because in statment 1 of or()condition returns true.

How can we conditionally display content in lightning component?

Step1 : Create a component which appear when entered value is true. Step2 : Create a component which appear when entered value is false. Step3 : Create component to show the above two component on the basis of condition.

What is Aura attribute?

An aura attribute is like a variable that we use in programming language or in Apex class. These are typed fields and set on a specific instance of a component. These attributes can be used inside the component as expressions and in controller and helper as well.

Final Output → To get source code live demo..

Hi, This is Vijay behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Originally published at https://www.w3web.net on April 25, 2022.

--

--