2069
Views
6
Comments
if expression
Question
Application Type
Reactive
Service Studio Version
11.53.26 (Build 61639)
Platform Version
11.18.0 (Build 37385)

Hi all, I'm creating a reactive web app. it's about recording working hours of the employees. I want to create an if statement for the numbers of hours:

if working hours >= 8, then "Working hours are complete" message should shown, 

else Working hours < 8, then "Working hours are incomplete" should shown.

I'm looking for resource to learn the if expression, and how it works in Outsystems, but I couldn't find them in the documentation.

So, can anyone recommend me any good source.

2022-08-03 04-32-50
Ravi Punjwani

There are several types of IF expressions in Outsystems:

  • Client Action IF element
  • Server Action IF element
  • UI IF Element
  • Inline IF statements (which work in all three above)

More details about your use case, and any specific problem you're facing with it, can help us better in recommending any learning source or a solution.

2024-09-17 18-14-33
Miguel Defavari da Silva

Hello Ali,

As Ravi said, there is more than one type of 'If' you can use in Outsystems, they are all basically the same concept with different implementations.

Here is some basic documentation you can check out:

https://success.outsystems.com/Documentation/10/Reference/OutSystems_Language/Logic/Built-in_Functions/Miscellaneous#If

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Interfaces/Designing_Screens/If_Widget

Best regards,

Miguel

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Ali,

Like Ravi said, there's different types of Ifs.

In a screen, there's the If widget, the documentation of which you can find here. It is used to hide or show certain parts of a screen, or toggle between two alternatives. Like all UI widgets, you can find it in the widget panel on the left, it's one of the top ones:

Inside the If widget's Condition property, you put an expression that evaluates to a boolean value.

In your code, there's also If tool, visualised as a node in your OutSystems code. When designing logic, it can also be found in the widget panel. It's documentation can be found here.

This If, too, has a Condition property that needs a boolean expression:

The If for server-side actions (server actions, service actions, REST/SOAP methods) looks similar:

The last If is the If built-in function. It's used in expressions. And althoug it looks like a function, and the documentation says it's a function, it isn't quite a function. That's because like most programming language's ifs, only the part that is returned gets evaluated. So you can safely write things like:

If(x <> 0, 10 / x, 0)

Note you couldn't do that when If was an actual function, as all function parameters are always evaluated before the function is called. As you can see (and read in the documentation I linked above), the If "function" has three parts: a condition to evaluate, the part that gets evaluated and returned when the condition is True, and the part that gets evaluated and returned when the condition is False.

As a last recommendation, please start your OutSystems journey with one of the Guided Paths, specifically the "Becoming a Reactive Web Developer" one. You will learn the basics of OutSystems along the way, and won't have to ask such very basic question as "what's an If in OutSystems" 😉.

2022-12-09 04-50-17
Shubham Doshi

Hello Ali,

If statement is a conditional statement where you can perform a action or you can display information depending upon the condition.

Syntax for If statement is:

If(<condition>,<what happens if condition is True>,<what happens if condition is False>)

Depending on the scenario you have given,

Your <condition> would be 'Working hours >= 8'

The If statement would look like below:

If(Working hours >= 8,"Working hours are complete", "Working hours are incomplete" )

or you can do it with the other condition 'Working hours < 8' but this time statement will execute exactly opposite as shown below.

If(Working hours < 8 ,"Working hours are incomplete", "Working hours are complete")


Hope this helps you :)



2022-06-06 09-58-43
Gourav shukla

Hello Ali,

             if you want to write the condition in expression so use If(Working hours >= 8,"Working hours are complete", "Working hours are incomplete" )  or if you use IF widget then write condition  Working hours >= 8 in IF Widget and pass the message in true branch "Working hours are complete" and false branch "Working hours are incomplete" .

Thanks

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Gourav,

Please check whether there are already answers when answering a question. There's nothing new in what you posted compared to the other answers.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.