Heyy, I want to pass a array to python function which can have min 0 max 3 values, when passing array with 0 values it is running good but when I’m trying to append value to array I’m not able to pass it to function what can be the problem can some one please help. “Assign: Object reference not set to an instance of an object.” this is my error
Hi @devanshi,
if you not initialization use the below syntax as default value.
new Object(){}
Like this
Thanks,
Object reference not set to an instance of an object" typically occurs in programming when you’re trying to access or manipulate an object that has not been properly initialized or is null. This issue can occur when working with arrays in UiPath and passing them to Python functions. Here are some common reasons and solutions for this error:
- Check for Null Arrays: Ensure that the array you’re trying to pass to the Python function is not null. If the array is empty or not properly initialized, you might encounter this error. You can check if the array is null or empty before passing it to Python.
Example : -
If myArray IsNot Nothing AndAlso myArray.Length > 0 Then
' Pass the array to the Python function
End If
- Initialize Arrays: If you’re appending values to an array, make sure that you initialize the array properly before appending values to it. You can use the
New
keyword to create a new array.
Eample : -
Dim myArray() As String = New String() {}
- Ensure that the data types you are using in UiPath are compatible with the Python function you are calling. If there is a type mismatch, it can lead to this error.
Make sure your assigned variable to array is having some value
Or
Try to do like this
- Use a list variable instead of array and initiate like this in a assign activity with values u want
U can do this if you have values ready already
Listinput = New List(of string) from {“value1”, “value2”}
If not ready with value just this
Listinput = New List(of string)
Where listinput is a variable of type System.Generic.Collections.List(of string)
U can search for this in variable panel
- Then add values to this list using activity
Listinput = Listinput.Concat({“Item1”,“item2”,“item3”}).ToList
- Then change that list to array like this
Listinput.ToArray()
Hope this helps
Cheers @devanshi
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.