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
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.
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