Datatable column names

How/Where do I define the columns of a datatable? When I define a variable in studio with a type of datatable that seems to be the end of it but nowhere have I said what columns are in it. I think I have the same question about defining an array. Without columns the datatable and array are just a list.

1 Like

Hi @chuck.jowett
Use the activity “build datatable” to define your columns and their types.
For array type, once you’ve created the variable, you can initialize it using “Assign” activity.
Here’s an example for an array of strings:

Hope that helps :slight_smile:

Thanks Emira, I wasn’t seeing the Datatable box on the activity but once I saw it, definition was straight forward. :grinning:

1 Like

One further question, do I have to explicitly define my data table column names outside the activity as well as in the activity? I’m getting a waning in Studio that they aren’t defined when I try to use them as targets in assign statements.

1 Like

You only need to define column names and types in the build datatable activity.
Now if your datatable is the result of a « read range » excel activity for example, then you don’t need to define any columns, the datatable will take the structure of the excel table.
Can you share a screenshot on the error/warning you’re having and how you are assigning columns?

In the first screen shot you can see I have defined a variable as a data table and you can see the activity Build Data Table with the column names. In the second screenshot you can see that the column name is unknown to the Assign statement.

Thanks for your help

I assume you’re trying to save the extracted value in the corresponding column: you can’t call the datatable column directly in the output.
Save the value in a new variable, let’s say FName.
Then using assign activity:

YourDatatable.Rows(RoxIndex)("columnName") = FName

Let me know if this is what you’re trying to achieve

Hi @chuck.jowett ,

The Error states the dt_FullName is not declared, either you have declared it within a Different Scope and it is not accessible else you are using the Wrong variable as a Different variable is shown in the First Screenshot.

Also, To Add rows to Datatable (If Datatable rows are Empty), you would need to use Add Data Row Activity.

Let us know what if you were able to perform your task using the information provided.

That is it, exactly. Thanks again.

1 Like

I suspected that given that the columns are define dynamically through an activity that there would be an activity for adding/deleting rows but why doesn’t the documentation make that clear?

You can use this activity to add a row to the datatable

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