If condition with two variables

Dear all,
I am trying to have an if-condition comparing two variables (var1 & var2) extracted out of two different data tables.

Both variables have the following form: 31116334 / 40060 (as example, meaning always 8 digits+empty space+/+empty space+5 digits)

If var1 = var2, then continue and if not then error message.

What I have tried so far, did not work, also the variables were the same:
var1 = var2
var1.equals(var2)
var1.contains(var2)

How must the if condition be created in detail to work properly? Thank you for support!

Hi,

I suppose both strings are not same exactly.
Can you try to check both string as the following with Write Line activity?

String.Join(",",var1.Select(function(x) ascw(x).ToString).ToArray)

String.Join(",",var2.Select(function(x) ascw(x).ToString).ToArray)

This expression returns character code of the string like 51,49,49,49,54,51,51,52,32,47,32,52,48,48,54,48.
and we can know if there is difference between var1 and var 2.

Regards,

what error u are getting?
Or is that condition is not working
Then check out both variables in message box and in log message so that u can rectify acordingly

@DirkKoch I guess you can try with the below expression :
var1.Trim.Equals(var2.Trim)

If it Stilll doesn’t match then the values should be actually different :sweat_smile:

I included the message box for both variables and they are identical. Nonetheless the if condition is not working?

I included the message box for both variables and they are identical. Nonetheless the if condition is not working?

Can you share workflow?

@DirkKoch, makes no sense why it wouldn’t work looking at what you have tried

Are you sure both variables are of the same datatype?

image

Hi Yoichi, the expression
51,49,49,49,54,51,51,52,32,47,32,52,48,48,54,48 is equal for both variables, but still the if condition is not working?

@DirkKoch Have you tried Deleting the If Condition and Implementing the condition again? Or Can you show the Screenshots of the If Condition that you have developed or better the workflow itself. Sometimes there might be a Bug and you can just close the Workflow and open it again and check if it works.

1 Like

Yes, I did, but w/o success. The Workflow is running fine, variables are created and match (checked with message box as well as write line activity) but if condition var1 = var2 returns as false.

@DirkKoch, do you mind sharing your workflow?

Buchungsbestätigung Shuttle BLS Final.xaml (249.5 KB)

Here you go. It is a draft and the structure is definitely not perfect. Thank you in advance for the support!

1 Like

@DirkKoch, lol yeah its kind of hard for me to understand the workflow and it looks like its not written in english.

Can you try put this in your if activity:

Projektbezeichnung.ToString.Equals(Bestellung3.ToString)

1 Like

I can imagine :slight_smile:
I tried your proposal but still w/o success. Since the variables are already declared as String, I would have been surprised if it would have worked. Any further ideas?

make sure both variables are the same type… cause if they are and the content is the same, this will never happen…

Both variants are String type & valid for complete Workflow. Still the problem occurs!?

Please dont suggest the IF condition might have a bug :slight_smile:

Hello @DirkKoch

Did you put a breakpoint, run in debug mode then check the variables compared (type, value)? Do you mind pasting a screenshot (with variables visible and expanded)?

Joining a screenshot of the actual comparison might help too.