IF ... ELSE IF not working as expected

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
lueu
Posts: 89
Joined: Tue Mar 07, 2023 11:49 pm

IF ... ELSE IF not working as expected

Post by lueu »

Hi!
On a rule made a while ago I used IF ... ELSE IF.. to do the same om several attributes, and this worked. Now I am making a rule to do something else, but this time the IF ... ELSE IF doesn't seem to work. It works on the first IF, but not on the ELSE IFs. What seems extra strange is that the columns in the database that doesn't get 99:99 as I want them to don't become NULL either, just empty? IF Mandag_TilKl was NULL, Mandag_TilTid would be NULL before trying this rule. If Mandag_TilKl now is changed and is NULL, Mandag_TilKl is empty... (see picture attached)

Any tips?

Rule:
IF BeredskapVaktRessurs.Mandag_FraKl IS UNDEFINED THEN BeredskapVaktRessurs.Mandag_FraTid = '99:99'
ELSE IF BeredskapVaktRessurs.Mandag_TilKl IS UNDEFINED THEN BeredskapVaktRessurs.Mandag_TilTid = '99:99' (and so on..)
Attachments
2023-05-05_10-44-13.png
2023-05-05_10-44-13.png (17.2 KiB) Viewed 1861 times
hpl123
Posts: 2594
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: IF ... ELSE IF not working as expected

Post by hpl123 »

Ifs works in strange ways sometimes so try breaking them up in separate rules instead. I don't know why this happens but could possibly be that the ifs look at different attributes so the first rule looks at the FraKl and the second TilKl etc. (I have seen similar behavior before when I used ifs and different attributes so nowadays I almost always break the ifs into a lot of single ones instead of doing complex multi/different attribute ones and I never see these types of issues any longer).
Henrik (V8 Developer Ed. - Windows)
joben
Posts: 224
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: IF ... ELSE IF not working as expected

Post by joben »

Agree with hpl123.
Regards, Joakim

Image
lueu
Posts: 89
Joined: Tue Mar 07, 2023 11:49 pm

Re: IF ... ELSE IF not working as expected

Post by lueu »

Thanks, I actually tested to put one line in a separate rule, and that seems to work. So I'll just have to do that for the rest too, then. 14 rules to cover one action :roll: :lol:
Post Reply