How can I use ifelse statement in the change object tool?

0
for example, if TimeLeft > 0,  TimeLeft=Time/TimeLeft – 1, else TimeLeft  = ​TimeLeft​​
asked
6 answers
0

Assuming $TimeLeft is a variable of the same type as TimeLeft attribute of entity Time

if $TimeLeft > 0 then

$Time/TimeLeft – 1

else

$TimeLeft

answered
0

Hello, 

Take a look at: https://docs.mendix.com/refguide/if-expressions  for the documentation

For your specific case:
if TimeLeft > 0
   then TimeLeft=Time/TimeLeft – 1
else
TimeLeft  = ​TimeLeft​​

answered
0
if $Time/TimeLeft > 0
then
  $Time/TimeLeft - 1
else
  $Time/TimeLeft
  

 

answered
0

Yes, you can use it in the Change Object action. 

You’ll need something like this

if ($Time/TimeLeft > 0) then
  $Time/TimeLeft – 1

 

answered
0

Like this:

Regards,

Ronald

 

answered
0

In addition to those answers, it’s recommended to check first if TimeLeft is not empty. If it’s empty you will get an error.

if $Time/TimeLeft != empty and $Time/TimeLeft > 0 then
   $Time/TimeLeft - 1
else
   0

 

   

answered