How to check multiple If conditions in sighlty | Community
Skip to main content
Level 4
January 11, 2023
Solved

How to check multiple If conditions in sighlty

  • January 11, 2023
  • 2 replies
  • 1321 views

Hi Team, 

I'm trying multiple if conditions for my code. as far as i know the below conditional check 

 

value ="${properties.val1 ? properties.val1 : inheritedPageProperties.val1}">

for this i need to add another default value , like if the value is present in component dialogue it should take from component else it should take from rootpage properties. If the value is not preset in both component and rootpage then I need to give my own default value?("some text").

 

how can I do this ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by cshawaus

@tessa_learner1 You can wrap your ternary expression in parenthesis and use an OR (||) condition to achieve this.

${(properties.val1 ? properties.val1 : inheritedPageProperties.val1) || 'Default'}

 

2 replies

AsifChowdhury
Community Advisor
Community Advisor
January 11, 2023
<sly data-sly-set.value="${properties.val1 ? properties.val1 : inheritedPageProperties.val1 || 'default value'}"></sly>

you can try this way.. In this ternary condition if ${propertise.val1} is not present then it will check ${inheritedPageProperties.val1} and if ${inheritedPageProperties.val1} this value is also not present then it will take the default value provided by OR(||) condition

cshawaus
cshawausAccepted solution
Level 2
January 11, 2023

@tessa_learner1 You can wrap your ternary expression in parenthesis and use an OR (||) condition to achieve this.

${(properties.val1 ? properties.val1 : inheritedPageProperties.val1) || 'Default'}

 

Level 4
January 11, 2023

Hi @cshawaus , 

Thank you so much for the response. I tried this, it's working.