Check Whether String is Empty or not in UiPath.

Do you use String or Queue Items in your automation process and want to know if a specific transaction item is empty or not?
The following issues will arise if the check is not received or done:

  1. An object reference is not set to an object instance.
  2. If it is a Queue item and the column specified is not available, the Given key is not in the dictionary.

In this article, we’ll look at how to avoid these two errors, as well as how to determine whether a specific transaction item or String is empty or not.
In general, we use the syntax below to determine whether a string is empty or not.

String.IsNullOrEmpty(inputvariable)

In UiPath, IsNullOrEmpty() is a string method. It is used to check whether the specified string is null or an Empty string. A string will be null if it has not been assigned a value. A string will be empty if it is assigned “” or String. Empty (A constant for empty strings).

Explanation: This method will accept a parameter of type System. This method takes a string and returns a boolean value. Return True if the str parameter is null or an empty string (“”), otherwise False.
The syntax above is typically used for a variable of variable type String.
Usage:

Output

String.IsNullOrWhiteSpace(inputvariable)

IsNullOrWhiteSpace() is a string method in UiPath. It determines whether the specified string is null or only contains white-space characters. A string is null if it has not been assigned a value or has been explicitly assigned the value null.

Explanation: This method will take a parameter which is of type System.String and this method will return a boolean value. If the method’s parameter list is null or String.Empty, or only contains white-space characters then return True otherwise return False.

Unlike IsNullorEmpty, IsNullOrWhiteSpace returns the character for white space as True.

Usage

Output

To summarize, use IsNullorEmpty and IsNullOrWhiteSpace to determine whether a string is null, empty, or contains blank space. The second issue that usually arises in these scenarios is that the given key is not in the dictionary: This is because the column name specified in the syntax is incorrect. Simply pass the correct column name to fix this. This is how you determine whether a Queue Item is empty or not, as well as the challenges that come with it.

Leave a Reply

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