Test Data Manager

  • 1.  Javelin : How to invoke DataTable Merge method?

    Posted Feb 22, 2017 12:56 PM

    I want to merge output of two DataTable objects in Javelin. Can you please advise a way out ?. I tried with dummy expression in assignment activity but it fails saying "Expression doesn't produce a value".

     

    I even tried with invoke method for '<data table object>.Merge" but it say any of target object doesn't has public static name in Merge Method..

     

    I am literally stuck up with option to run couple of VB commands in a workflow.



  • 2.  Re: Javelin : How to invoke DataTable Merge method?
    Best Answer

    Broadcom Employee
    Posted Feb 22, 2017 01:19 PM

    Yep, you were very close!

     

    1. The missing key to this all is the 'Parameters' property of InvokeMethod


    2. Now we need to create our one 'In parameter' (in this case, the table we want to merge in)


    3. Now it should be done! I will attach the example file, where it brings in two datatables, merges the second into the first, then prints out the number of rows in the first.

    Attachment(s)

    zip
    Data table merge.vwf.zip   1 KB 1 version
    zip
    csv1.csv.zip   151 B 1 version
    zip
    csv2.csv.zip   154 B 1 version


  • 3.  Re: Javelin : How to invoke DataTable Merge method?

    Posted Feb 22, 2017 01:22 PM

    Thanks a lot Benjamin,

     

    Do u have any use case to add a row or column in data table as well ?



  • 4.  Re: Javelin : How to invoke DataTable Merge method?

    Broadcom Employee
    Posted Feb 22, 2017 01:30 PM

    I don't have an example to hand, but it should be of the same pattern we just used.

     

    TargetObject -> Datatable1.Rows 

    MethodName -> Add

    Parameters -> In,DataRow,YourDataRowToAdd

     

    So you'd go and get the appropriate object to act on say Datatable1.Rows (which is a DataRowCollection), and then call 'Add' on it. 

     

    Here is a link to the appropriate types:

    DataRowCollection Class (System.Data) 

    DataColumnCollection Class (System.Data) 

     

    And here are links to the appropriate properties:

    DataTable.Rows Property (System.Data) 

    DataTable.Columns Property (System.Data) 

     

    Of course, this presumes you have a DataRow/Col to add in.


    You could always build an extension which allows you to add say a Column in just by a string.



  • 5.  Re: Javelin : How to invoke DataTable Merge method?

    Posted Feb 22, 2017 01:35 PM

    Got it,

     

    while i was trying Merge invoke as mentioned above. I am getting a run-time exception

     

    Value cannot be Null

    Parameter Name: TargetObject



  • 6.  Re: Javelin : How to invoke DataTable Merge method?

    Posted Feb 22, 2017 02:34 PM

    while i was trying Merge invoke as mentioned above. I am getting a run-time exception

     

    Value cannot be Null

    Parameter Name: TargetObject