How to use "mod" in If action

Chould you give me some advice about how to use mod() in if.

I want to use like this in if.

Mod(GetXXX.List.Length,x) >= y and Mod(GetXXX.List.Length,x) < z

I try to use this in Local Action on mobile, but return value is "false" anytime.

I put "Mod(GetXXX.List.Length,x)" by Expression on Screen, then it's value is "true".  

I can't figure out what is wrong...

Thanks.

Hi Yumiko,

There seems to be nothing wrong with the Expression itself. Did you debug and check the values of Length, y and z?

Hi Yumiko,


The "If" where you get always false, is in the preparation? If yes, are you using values that, at that point ,aren't yet calculated? In the expression you use in the screen, the values are already calculated, but if you are using that in the preparation with values that wasn't calculated yet, you can always have false.


Hope this can help.


Best regards,

Ricardo M Pereira

Thanks your help!

I'm beginner of Outsystems. If my explain is short, please tell me what is necessary information.


>Kilian

I want to make Action what List.Length divided by 5 then remainder of 1.

I tried to put this in Screen Expression, result is "true". 

If(Mod(GetXXXX.List.Length,5) = 1, "true","false")

And I put this in Local Action, then result reached "false".

I thought it go to reach "true" and  go to Switch, so I confused.


>Ricardo

I used this in Local Action on Mobile. And I set this action on "On Initialize" by Screen Events.

It was not calculated yet...? Could you give me advice how to calculate it when screen is opened.


Thanks.

Solution

Yumiko Ueyama wrote:

Thanks your help!

I'm beginner of Outsystems. If my explain is short, please tell me what is necessary information.


>Kilian

I want to make Action what List.Length divided by 5 then remainder of 1.

I tried to put this in Screen Expression, result is "true". 

If(Mod(GetXXXX.List.Length,5) = 1, "true","false")

And I put this in Local Action, then result reached "false".

I thought it go to reach "true" and  go to Switch, so I confused.


>Ricardo

I used this in Local Action on Mobile. And I set this action on "On Initialize" by Screen Events.

It was not calculated yet...? Could you give me advice how to calculate it when screen is opened.


Thanks.

Hi Yumico,

Because you are calling this client action in OnInitialize so before you get the data from screen aggregare this calculation gets completed when list length is actually 0.

So the best place for you to call this client action is onafterfetch event of your screen aggregate which you can create by selecting your aggrigate and create from its properties.

I will recoment you to do you training first so that you are aware of the lifecycle and you do not face similar issues.

https://www.outsystems.com/learn/paths/1/becoming-a-mobile-developer/

Solution

>Nikhil

Thanks your advice!
I figured out that.And I set it aggregate's "on after fetch", I got correct result it.
I misunderstood about "On Initialize" as after fetch aggregate. It's after splash, and before fetch aggregate, right?

I'll try to learn by your recommend training.I would appreciate it if you would help me if I should encounter any problems.


Thanks for everyone, and best regards,

Yumiko