Problem with IfElseIf activity

Hi all,

I have observed an error in behaviour of the UiPath.Core.Activities.IfElseIf activity. It seems that the activity evaluates the “Else-If” condition even if the initial “If” condition is True. This is causing unexpected behaviour and in some cases errors, especially when the initial “If” condition is checking for null and the “Else-If” condition assumes the value is not null.

Has anyone observed the same?

I uploaded a simple XAML (we are using Studio 2022.10.10/Windows/VB mode) to reproduce the error. In summary: if the ‘name’ string is null/Nothing we are still getting a null-reference exception, even though the initial IF statement is checking for that.

Thanks in advance for any feedback and suggestion.
Robert

Tester_01_MISC.xaml (7.6 KB)

1 Like

Hi @Robert.Oslanec ,
Can you share image about activity?
your version is standard?
I use newest version 2023.10
regards,

Hi,

In my environment : Studio 23.4.2+System activities pacakge23.4.4, the problem can be reproduced.

I think it’s probably a bug.

Regards,

Hi Nguyen,
here is the screenshot of the activities I was using. The Studio is 2022.10.10.
Kind Regards,
Robert

Activities versions

Hi Robert,
I have check it
if we assign name = Nothing
→ it will not working


but
if you assign name = “”
→ it will working

When we assign to Nothing
I try some way but it will not working
name is Nothing
stringNullorEmpty(name)
my package

Thank you both for checking this out.
I believe this is a bug, I raised a support ticket with UiPath for it.

Yes, you can send ticket to tech support
I think this activity can understand Nothing with blank or null string

Nguyen, yes, when you assign string.Empty (or “”), there is no error, but its because the name.Equals() method can be executed safely.

I just found it bizzare that the ELSE condition is executed even when the IF condition evaluates to True. I believe that should not happen, hence I think its a bug.

Yes, Robert
Hope it will better in next time,

Hi @Robert.Oslanec

Unfortunately, this is a current technical limitation of this activity. We have clarified this a bit in our documentation:

The crucial bit:

NOTE:
Before the Else If activity is actually executed, all conditions are evaluated first. This can cause side-effects like exceptions. To avoid this, add extra checks in the ELSE condition

Hi Maciej (@loginerror ),

thank you for updating the docs. Its useful to have that added for developers.

Kind Regards,
Robert

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.