GenericValue.ToString returns NullReferenceException

datatable
excel
uiautomation
uipath

#1

I have a read range activity and after which I have a get row item inside a for-each loop to get the items.
The Get Row Item returns a Generic Value object. I have a write line which prints the value, but throws an error when I’m trying to do ToString operation on it. Error is as below.

Main.xaml (19.5 KB)

Invoice Template copy.xlsx (16.1 KB)

###############################

Main has thrown an exception

Source: Write line

Message: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized).

Exception Type: NullReferenceException

System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


#2

Hi,

tableItem returning null value and .tostring doesn’t handle null value hence the error.
Just pass tableItem not tableItem.tostring.
check now.
Main (12).xaml (19.5 KB)


#3

Hi,

Bro remove “.Tostring” From WriteLine and put tableItem… its working perfectly…Generic.xaml (19.4 KB)


#4

I want to check for a condition if the tableItem contains a part of string. So I’m converting it to string. Write line prints the content without problem.


#5

just change generic type to string in variable pan and proceed further.


#6

Cant do that. Get row item throws error. Invalid L-value expression Reference expression cannot end with Conversion.


#7

Here we go.
Main (12).xaml (19.4 KB)