Application Studio - Pass Tableset to Function

Is it possible to create a Function that has a Tableset as the Request Parameter and pass a Tableset to it through App Studio?

Your best bet is to convert the tableset to a generic dataset with Ice.DatasetAdapter.ConvertToGenericDataset, then serialize the dataset to XML through .WriteXml(), encode the XML to Base64, and pass it as a string. On the receiving side, you can decode the base64 string back to XML, and use .ReadXml() to deserialize it back to a dataset.

Otherwise, the dataset gets converted to JSON arrays and you lose extended properties, column types, deleted rows, original rows, etc…

EDIT: Sorry I just saw you wrote through App Studio… This won’t work in app studio, due to no code and all…

2 Likes

With today’s API-first development, the Epicor/Kinetic details are hidden from the client and the API will exposed a shaped view that references an OpenAPI(Swagger) specification to describe data types, mandatory items, etc.

In your case @jkane, an Epicor Function seems to be the way Kinetic screens do what you are asking. I have to keep reminding myself not to code in the client as we see daily the various issues it causes with upgrading, security, performance, …

2 Likes

That’s a bit of a corporate cop out if you ask me. A proper service would pass objects unmolested and loss-less… But whatever, I’m not going to die on that hill this morning… :wink:

I’m not sure what you mean by this LMAO
OpenAPI is a standard… dare I say “The” standard for RESTFUL Services and APIs not sure what you mean by “unmolested” the data you get out of the REST API is “The data” that the API expects and understands…

Try passing a dataset to a function from a customization or a BPM, you will see what I mean… Everything becomes strings! I’m not knocking on OpenAPI, it does have provisions for offering strongly typed services, it’s just not being used…

Any luck with this issue?

I also want to pass a Tableset to perform some complex logic on the backend.

There are a few posts out there that show how to do this. You’ll need to search for them.

I think I figured it out.

you need to pass the Dataset ID of the DataView.

image

image

I tested it and it works fine.

Doing something similar but my Data view comes from a BAQ

There is no Dataset ID in that case.

I tried the view names but the dataset goes through empty - zero tables. Same if I use the BAQ ID.

Hi Tim,

Leaving the DatasetID ( Parameter Name) blank works for you?
I’m doing the same passing a BAQ View to a function but it’s just not receiving the data.
Tried blank, “Results”, BAQ Name, View Name but none work.

Many thanks

Mark

Couple things to try:

  1. Put curly braces around your data view name
  2. Set it up in the Request Parameters section instead of Method Parameters. I don’t have an example for this as I’m currently on my phone.
2 Likes

Hannah I will give that a shot!

Mark , no leaving it blank did not work. I had to stringify the dataview… MassTransfer is my dataview. See below.

InDS is a string parameter on my function

#_JSON.stringify(trans.dataView('MassTransfer').viewData)_#     ```


**And in the function**


var JSON_array = Newtonsoft.Json.Linq.JArray.Parse(this.InDS);  /// Need to add Newtonsoft.Json assembly as a reference

foreach (var data in JSON_array)
{

     counter++;
   
   bool selected = (bool)data["Calculated_Selected"];
   
   string partNum = (string)data["PartBin_PartNum"];
   string warehouseCode =  (string)data["PartBin_WarehouseCode"];
}

Thanks Tim,

I did get it to work in the end - it was “Results” for the dataset name.
Thanks for getting back to me.

Mark

Awesome! Did you use stringify or Hannah’s method?

I want to get her method to work, it looks cleaner and will be easier to maintain and explain :slight_smile:

Hi Tim,
Sorry for the delay - I used Hannah’s method, however I notice a MAJOR drawback with this so have reverted to your method as it work brilliantly (thanks!). The issue with passing the dataview over is if you have mixed datatypes, for example first line “Net” field is an integer, if any subsequent are decimal it is treated as an integer and gives erroneous data!
Kind regards
Mark

1 Like