Function question: How to pass a DataSet or DataTable to a function?

I’ve been using REST to call a function I created to call the AP Invoice Post method sending a Group ID, but now I want to pass a dataset or datatable from C# to a function or functions that would create the group and populate it with PO-based invoices. Has anyone done anything like this? I would greatly appreciate the help!

What are you struggling with? DataSet is one of the supported out of the box options without any references.

You can also pass some other objects depending on your function references.

1 Like

Trying to work out how to pass in a dataset with two tables, one with APInvHed data and the other with APInvDtl data, then know what column is what in the function. If I use just a Systen.Data.Dataset, it won’t pass any column names or datatypes, will it?

I’m sure there are better ways to do this but I’ve been passing DataTable arrays as a string

using Newtonsoft.Json.  

//serialize object as a string
var myparm = JsonConvert.SerializeObject(myDs);
//then call function using myparm as a string..
//string errormsg = this.EfxLib.MyLib.SendMeDataTable(myparm);
//Deserialize within invoked function:
var myDs = JsonConvert.DeserializeObject<DataTable[]>(myinput);

Column names, yes, datatypes no.

But that can be worked around.

If you could explain in detail, I’ll be back on later.