If Statement condition is not working

My bot is entering invoices into SAP. If no document Parked 19**** appears, I want the bot to go back to the top screen and type /n enter to get out of that invoice. move the file with issue out of the folder and go to the next invoice in the folder. Please let me know if I have the condition stated correction?
“string”.Contains(“1000 was Parked”)=false

its taking hardcoded value “string” for the check
this never will contain 1000 was Parked
so this condition will always be true

We do feel that you want to do it with a variable instead

You don’t use “=false” or “=true” in If conditions. That is implied because you’re using the If.

Just put “string”.Contains(“1000 was Parked”) in the condition of the If.

Then the “Then” part of the Activity is where you put the code you want to run if the condition is true, the “Else” is where you put the code to run if the condition is false.

Thank you so much. another question:

So if SAP says anything other than “1000 was Parked 19*) the bot should do the else. Is there a time limit to put on the bot to do the else? It is just sitting there with the error message and not moving forward. The rest of the process for errors:

Yes but why are you using “string”.contains?

That literally means if “string” contains some other text. “string” will never contain anything other than “string” - putting it in double quotes makes it a literal.

“string”.Contains(“1000 was parked”) will ALWAYS be false. “hello”.Contains(“hello”) will ALWAYS be true. “string”.contains(“string”) will ALWAYS be true.

Generally you have a value in a string variable and then do this…

myStringVar.Contains(“some text”)

Also, I’m not a big fan of If statements where only the Else (false condition) is filled in. Another way to do it would be…

NOT myStringVar.Contains(“1000 is Parked”)

And then fill in the Then portion instead of the Else portion. Just looks cleaner.

1 Like

Thank you. I will try that.

Thank you.

Terri Kasher

Fuel Credit

Wawa, Inc.

610.306.0009 (C)


Hi Paul

I received the below error message when going for the Not myString? Am I missing something.

You didn’t create a variable named myStringVar.

I’m not saying to literally use myStringVar. It’s just a general example. The “Contains” operator is executed against whatever you provide before it. So if you do myStringVar.Contains(“hello”) it looks for hello in the value of the myStringVar variable. If you do “test text”.Contains(“hello”) it looks for hello in “test text” (which will never be true since “test text” is a literal and will never contain hello. If you do customerName.Contains(“John”) it’ll look for John in whatever the value is of the customerName variable.

Thanks Paul

Sorry for all the questions. We are pretty new to UiPath—before last year we were heavily into creating our bots, but the past year we have not had too much time to be involved in adjusting/creating anything bot. Sort of forgot a lot.

So thank again.


Hi Paul

My if statement is still not working even after creating variable. Maybe I should explain a little better.

After the bot runs and parks a document there is text at in SAP Document 1000 was parked 19******. If that happens the bot goes to the next invoice and repeats—that is working.

If there is anything other than Document 1000 was parked appears, then I would like it to follow the other side of the If Statement—note there are many different text options that could appear in SAP—these are usually error messages if the document does not get parked.

This is the beginning of my IF statement. Let me know if you think there are better activities for this process.

It isn’t clear what isn’t working. What is documentNumber? Is it not ending up with a value?

I have a Get text activity that pulls the document number if it is parked in SAP. if 1000 was parked …. If that does not appear—documentnumber is nothing and that is a variable.

So what part of the If you posted isn’t working?