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

**URL:** <https://www.epiusers.help/t/function-question-how-to-pass-a-dataset-or-datatable-to-a-function/105347>\
**Category:** Epicor ERP 10\
**Tags:** kinetic, functions, e10, epicor\
**Created:** [July 24, 2023, 8:10pm UTC](https://www.epiusers.help/t/function-question-how-to-pass-a-dataset-or-datatable-to-a-function/105347 "2023-07-24T20:10:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JMyers56](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/ec9cab/32.png) [@JMyers56](https://www.epiusers.help/u/JMyers56)\
**Post date:** [July 24, 2023, 8:10pm UTC](https://www.epiusers.help/t/function-question-how-to-pass-a-dataset-or-datatable-to-a-function/105347/1 "2023-07-24T20:10:41Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [July 24, 2023, 8:14pm UTC](https://www.epiusers.help/t/function-question-how-to-pass-a-dataset-or-datatable-to-a-function/105347/2 "2023-07-24T20:14:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JMyers56](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/ec9cab/32.png) [@JMyers56](https://www.epiusers.help/u/JMyers56)\
**Post date:** [July 24, 2023, 8:43pm UTC](https://www.epiusers.help/t/function-question-how-to-pass-a-dataset-or-datatable-to-a-function/105347/3 "2023-07-24T20:43:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tanner](https://www.epiusers.help/letter_avatar_proxy/v4/letter/t/439d5e/32.png) [@tanner](https://www.epiusers.help/u/tanner)\
**Post date:** [July 24, 2023, 9:14pm UTC](https://www.epiusers.help/t/function-question-how-to-pass-a-dataset-or-datatable-to-a-function/105347/4 "2023-07-24T21:14:23Z")

</div>

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

```cs
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);
```

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [July 24, 2023, 9:19pm UTC](https://www.epiusers.help/t/function-question-how-to-pass-a-dataset-or-datatable-to-a-function/105347/5 "2023-07-24T21:19:14Z")

</div>

> [@JMyers56](#):
>
> column names or datatypes

Column names, yes, datatypes no.

But that can be worked around.

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