Invoke code:

Hi Guys may you kindly please assist me i am using invoke code to loop through datatables compare values and add to another datatable but i get an error Invoke Code: Exception has been thrown by the target of an invocation.
InvokeCode

Hey @mpho.ndoweni ,
Can Check for null value… Ensure that you are handling null or empty values properly
Also its better to Add exception handling…Surround the code inside the “Invoke Code” activity with a Try-Catch block. This way, you can catch any exceptions and log the specific error message for debugging.
Use a Write Line or Log the exception message or direct the exception to an out argument such that we can handle the Exception in a better way.

Based on the Exception message we can understand the issue being faced.

Hi,

For now can you check content of $ExceptionDetails in Locals panel when error occurs in debug mode? Probably there is detailed information for the exception.

Regards,

Hey thanks it appears the error occurs when i declare a new row on dim newrow As DataRow = out_dt_nedbank_comapare.NewRow

Hey Thanks yes it appears the error occurs when i declare new row

HI,

Can you share whole content of $excceptionDetails?

Regards,

Ohh,Also Surround the code using Try catch for best practices!

Happy Automation! :slight_smile:

Exception

Hi,

I guess out_dt_nedbank_compare is null. So can you try to add either of the following expression at the beginning of the code?

out_dt_nedbank_compare = in_dt_nedbank.Clone

OR

out_dt_nedbank_compare = in_Dt_Comparison.Clone

Regards,

Thank you so much Yoichi it is now working

1 Like

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