12
Views
4
Comments
Solved
OR operator in text with if statement

Is it possible to apply a OR operator in text with if statement?

I now get the following error:


How can i use the or statement in the if?(this is a IF statement)

Rank: #157
Solution

Hello Samed,

Yes it is possible :)


Your condition should be:

GetGegevenById.List.Current.Aanvraag_Voortgang.Label = "In_behandeling" or GetGegevenById.List.Current.Aanvraag_Voortgang.Label = "goedgekeurd"


EDIT: On my first answer (related to the condition above), I was just focused on how to show you how to use an OR operator in an IF statement :)

Anyway, going a bit further on your implementation, I also agree that comparing with labels is not the best practice and it is something that you should avoid to do in your code :)


Like Orla mentioned below, your condition should be something like:

GetGegevenById.List.Current.Aanvraag_Voortgang.Id = Entities.Aanvraag_Voortgang.InBehandeling or GetGegevenById.List.Current.Aanvraag_Voortgang.Id = Entities.Aanvraag_Voortgang.goedgekeurd


If you compare by labels in your code and if you change those labels sometime, this will lead into runtime problems in your application (because those conditions won't work as expected anymore). But if you do this comparison using the IDs of your Static Entity, you won't have this problem because OutSystems handles everything for you :)


Hope that this helps you!

Thank you Orla for your excellent addition to the thread! :))


Kind regards,

Rui Barradas

mvp_badge
MVP
Rank: #317

Hi Samed,

Rui gives you your answer. But it is better to use the Id of a static in expressions:

GetGegevenById.List.Current.Aanvraag_Voortgang.Id = Entities.Aanvraag_Voortgang.InBehandeling or GetGegevenById.List.Current.Aanvraag_Voortgang.Id = Entities.Aanvraag_Voortgang.goedgekeurd

The label should only be used to show a text on a screen. Labels can change and you won't get an error in Service Studio on your compare. If you use the Id like I showed, Service Studio fixes everything for you if the name changes.

mvp_badge
MVP
Rank: #76

Hi Samed,

I agree with Orla. Best practice is to use the Identifier of your Static Entity to do the comparison.

More information on how Static Entities should be used can be found here.

I hope you will consider to mark Orla's answer as solution.

EDIT: since Rui edited his post by adding the best practice for this case, it can stay marked as solution as far as I'm concerned :)

Regards,

Nordin