Hi,
I often keep data in DataTables, but have to pass data to be processed to a subroutine. In most cases I pass a single data row (i.e. out of a For Each Row loop) to the subroutine.
While executing the whole script this works fine, but while developing and testing I would like to set some explicit values for the data to be processed.
Is there a way to initialize the DataRow in the Arguments Panel with a Default Value?
Like New DataRow({“DataColumn1”:“Value”; “DataColumn2”:“Value”})
I do not want to use an Assign Activity as this would interfere with normal execution, where a value is passed when calling the script.
I could pass single values instead of a DataRow, but I think in most caes it is more convenient to stick with the DataRow.
Thank you for your answers, but they don’t help with my problem.
I know how to define a default value in Buil DataTable Activity.
But in my context the DataTable is defined in another script and just the DataRow is passed as an argument to be used in the subroutine.
This works fine when running the process. But I need some test data while developing the subroutine. So I need to populate the DataRow passed as an argument with test values.
So if I do not have a Default value for in_dt_TableRow the script runs into an error when trying to execute the message box activity.
I could probably build another test script to call my script I am working on with proper arguments but then I would have to test my whole script from the beginning and still could not test single activities.
Also I tried to check in my script, if I got proper values in my arguments but failed to do so. I tried an If-Activity to check the argument and it is recognized as a DataRow but I can not perform any functions on it as it is null. But I even get an error when I try in_dt_TableRow.isNull.
So I probably need a Default value for DataRow like I need for other argument types. But “New DataRow” is not accepted as Default vaule.
What could I use as Default value?
Or is there a better way to pass the values between subroutines?
Should I better pass single values? Or convert the DataRow to an array?
Both ways don’t seem very comfortable, especially when I have to change some values and return them to the main script.
detecting if in_dt_TableRow is null or not can be done within an if activity:
Condition: isNothing(in_dt_TableRow)
reacting on the evaluation you can check following approach.
on top of the xaml us a buld datatable,
configure the datacolumn structure as same the original datatable do have
fillout the first row with default values that you would like to use
in case of isNothing(in_dt_TableRow) = true then set the default row like
in_dt_TableRow = dummyDT.Rows(0)
However to avoid only the exception within the message box you can do following:
replace MessageBox with a log message, set breakpoint along with conditions (Academy Debugging course is highly recommended)
define Breakpoint, configure settings by right click on breakpoint
I tried in_dt_TableRow.isNull because the variable was listed as null in debug mode. I also tried in_dt_TableRow.equals(Nothing) (as there was no in_dt_TableRow.isNothing). But IsNothing(in_dt_TableRow) was new to me.
I alreday had implmented the if-Activity with Build DataTable and now with the correct condition it is working as intended.
It is a bit of work to do with different DataRows and DataTables passed around, but at least it works.