Issue with arguments - Object reference not set to an instance of an object

I am using the REFramework provided by UiPath, I am trying to create a DataRow (WIList) array (using an assignment) from a DataTable (WorkItems). I have confirmed the DataTable has rows, but when trying to create the array, I am getting the “Object reference …” error as following.

Any help would be appreciated.

Thanks!

Hi
Kindly check whether the argument WorkItems has any value in it or not
i think there is some issue with arguments direction or missing right argument usage

Kindly check whether the argument direction is right
or check whether the right argument is used
IN means it can be used only in that project
OUT means it can be used only outside the project
IN/OUT means can be used both inside and outside the project
–here i mean that argument usage as inside and outside

Cheers @mesalcan

I have changed the direction to IN/OUT on both sides, just to be sure I was not doing something incorrectly. WIList is created on this “Assign” activity, and still getting the same error.

Thanks!

Fine from where this argument WorkItems datatable is getting value

Cheers @mesalcan

This is gotten from a Data Scrapping workflow

Thanks!

Actually it should be like this
hope you have a separate xaml for CreateDataTable.xaml and is invoked in the main xaml
–if so the WorkItems argument is passed from the CreateDataTable.xaml to the mail xaml like in main xaml create a variable named in_workitems a variable of type datatable and mention the scope as whole sequence thus making it as a global variable
–then while calling the CreateDataTable.xaml with invoke workflow activity and after importing the arguments with import arguments option, goto argument property where for the arguments WorkItems with IN/OUT arguments be mentioned with the value in_workitems
–so the value from the invoked workflow is now passed to the global variable in the main xaml
–now pass this variable in_workitems as input to the assign activitly and use select method in that
hope this will work for sure
Cheers @mesalcan

Just use a “For Each Row” activity.

For Each Row inside WorkItemsDataTable
Assign Row to DataRow
Next Row

Though honestly, for the purposes of that Assignment, I’d just use “Get Row Item” inside a For Each Row of WorkItemsDataTable to find out whether or not that row is of the “Type” I need… If you’re on the assignment I think you’re on anyway.

For Each Row inside WorkItemsDataTable
Get Row Item (column “Type”)
If Row Item = “WI5” Then…
Assign… etc.
Next Row

Arguments of type DataTable do not accept default values @Palaniyappan

why default values
we are going to pass only while importing arguments with arguments property in the invoke workflow activity
Cheers @mesalcan

Do you have a Variable in your Main.xaml that your CreateDataTable.xaml is passing ‘WorkItems’ out to? When you click “Edit Arguments” on your CreateDataTable.xaml activity, is your WorkItems being passed (“Out”) to a variable of DataTable type in Main.xaml?

1 Like

I have done the suggested and getting same error:

Thanks!
@Palaniyappan

It looks like you’re trying to pass an empty/non-existent DataTable into CreateDataTable.xaml.
I understand the “WorkItems” DataTable is created inside CreateDataTable.xaml, right?

Inside your CreateDataTable.xaml, your “WorkItems” Argument should be called “out_WorkItems”
Create the DataTable inside CreateDataTable.xaml (data scrape with output to “out_WorkItems”)

Create a Variable of DataTable type in your Main.xaml called “dtWorkItems”

The “Import Arguments” part of the invoke of CreateDataTable.xaml should look like this:
[Name] - [Direction] - [Type] - [Value]
out_WorkItems - Out - DataTable - dtWorkItems

Your scraped DataTable (“dtWorkItems”) can now be used in Main.xaml or passed to (“In”) other workflows:

Create Argument in other workflow for “in_WorkItems”.
In the “Import Arguments” of other Workflow’s invoke, it should look like this:
[Name] - [Direction] - [Type] - [Value]
in_WorkItems - In - DataTable - dtWorkItems

This allows you to use your dtWorkItems in that workflow as “in_WorkItems”

I am guessing the argument name should not be that important or it is?
You are right WorkItems is being created in CreateDataTable
I have a variable called in_WorkItems that is valid within the entire project, why should it be named dtWorkItems?

Thanks!
@x.Rei.Ai.x

It doesn’t have to be called “dtWorkItems”. It’s just how I follow my own naming conventions so I know what’s an argument and what’s not an argument (i.e., a Variable). You can name that Variable in Main.xaml however you want - just make sure you’re renaming it in the Variables section of Main.xaml and that is receiving the DataTable argument (“out”) from your CreateDataTable.xaml.

Arguments are for passing variables from one workflow to another. I see you have Arguments listed in Main.xaml, which doesn’t really make sense to me, since you aren’t invoking Main.xaml anywhere in your Project (or rather, you shouldn’t be invoking Main.xaml anywhere). Main.xaml should only be receiving Arguments that are passed to Main.xaml and stored as Variables of Main.xaml. And those Variables are then passed to other workflows as Arguments.

If you want to pass variables from Main.xaml to other workflows as arguments, declare them as Variables in Main.xaml and as arguments in the Invoked Workflow.

If the variable is going into the Invoked Workflow as an argument and not coming back out of it: “In”
If the variable is going into the Invoked Workflow as an argument, being manipulated, and then coming back to Main.xaml as a variable: “In/Out”
If the variable is coming out of the Invoked Workflow, and is made in the Invoked Workflow as an argument: “Out”

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.