I am trying to pass a data table from StudioWeb into an Agent. The DataTable in studio web has more columns that what I am passing into the Agent. How do I only pass the columns I want (guidance on the expression would be great), or do I have to create a new DataTable with ONLY the columns I want?
List of Columns in my DataTable: ControlNumber1,ControlName,BankAccountNumber,StatementNumber,StatementLineNumber,TransactionDate,UserReference,Amount,Allocated,DebtorName,RMAReference,PaymentReference,BankTransactionCode
PS - it works well if I call it as I iterate through the table, but the problem is it then takes too long and times out when I am testing it.
Below the expresion when iterating through, I just can’t figure it out to do as a full data table:
Ideally rather than passing datatable it would be good if you take input as json array ..and datatable can be serialized as a json array and can be passed it is more freindly
A reference for converting to jarray here
Apart from that if tou want to pass datatable only with required columns then you can just filter datatable and pass columns you want..but agent can handle a jarray better I feel
I then try pass this to my Agent like this:
JsonConvert.SerializeObject(CType(ArrayofObject, List(Of Dictionary(Of String, Object))))
But still get this error message:
2025-07-24 15:00:03.763 GMT+5: Error: System.InvalidCastException: Unable to cast object of type ‘System.Collections.Generic.Dictionary2[System.String,System.Object][]' to type 'System.Collections.Generic.List1[System.Collections.Generic.Dictionary`2[System.String,System.Object]]’.
at Namespace_d0a7.Main_Expressions.Main_Expressions_TypedDataContext2_ForReadOnly.__Expr25Get()
at Namespace_d0a7.Main_Expressions.Main_Expressions_TypedDataContext2_ForReadOnly.ValueType___Expr25Get()
at Namespace_d0a7.Main_Expressions.InvokeExpression(Int32 expressionId, IList`1 locations, ActivityContext activityContext)
at Microsoft.VisualBasic.Activities.VisualBasicValue`1.Execute(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity`1 expressionActivity)
at System.Activities.InArgument`1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate)
at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Any chance we could hop on a call to solve this together?
Assign String variable as below as use same expression to convert String to Json: JsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(Datatable_Name)
The agent works well when I test it on its own with a JSON string, problem is calling it from my workflow. Somehow thinks the string is a file location and I dont know how to change that