Check Specific Transaction Item is Empty or Not UiPath

Are you using Queue Items in your automation process and want to check the specific transaction item is empty or not.

The issue that will arise while doing this are below:

  • Object reference is not set to an instance of an object.
  • Given key was not present in the dictionary.

In this article, we will see how to overcome these two errors and also how to check the specific transaction item is empty or not.

In general we check the string is empty or not by using the below syntax.

String.IsNullOrEmpty(inputvariable)

Here:

inputvariable- The input value for which you want to check whether it is empty or not.

The above syntax is normally used for a variable that is of variable type String.

As this is a variable type QueueItem it won’t work directly if you use the below syntax.

String.IsNullOrEmpty(in_TransactionItem.SpecificContent("Name").ToString)

If you use this syntax in If Condition it will give you object reference not set to an instance of an object as below.

specific item is empty

How to overcome this?

First Method:

First Create a variable of string type.

Let’s say in this example we will create a variable called Name and assign queue item value to it as below.

specific item is empty

Now, this Queue Item value is assigned to a string type we can the above-mentioned syntax here.

It won’t throw any error now.

Second Method:

In this method without assigning Queue Item value to any variable, we can check whether it is empty or not.

The syntax is as follows:

in_TransactionItem.SpecificContent("Name") Is Nothing

Here we won’t convert this to a String.

The second issue that normally arises in these scenarios is-

Given key was not present in the dictionary:

This is because the column name that we are giving in the syntax is wrong.

To rectify that just pass the correct column name.

This is how you check Queue Item is Empty or Not and the challenges that will come with it.

Happy Learning!

Like this post then let your friends know about this-:

Leave a Reply

Your email address will not be published. Required fields are marked *