Pass a dataview to a function for further processing

If you are trying to delete, many times if this is from a set of data the enumeration will get messed up when deleting front to back instead of back to front.

1 Like

RE: how can we send data or rows or selected row from a custom panel card grid to the function??

Know this an old thread , but helpful info for those looking to do this, found a way to send Selected Grid Row Field data to function with the following:

  • Use the Copy View instructions posted under write up titled “How To: Kinetic - Working with Grid Selectors”, in the associated ce_ADDRow iterate event, after the row-add component, added a ERP-Function component which passed the current CopyView row field to my function as a method parameter. It’s the little things … Cheers

Using ERP-FUNCTION in the Kinetic client, I was able to pass a dataset (view) from the Kinetic client to a function. In the ERP-FUNCTION, set the Method Parameter ‘Field Data Type’ to dataset, and set ‘Dataset Id’ to the view name, such as UD25View. In the server side function, set the Request Parameter type to System.Data.DataSet. It works.

2 Likes

@mmaurice

I am trying to do the same,
I have the dataview being passed as a dataset to my function,

I’m referencing the dataview using the following:
(iOrderDtl is the name of the function parameter for dataview OrderDtl)

iOrderDtl.Tables["OrderDtl"].Rows[i].

but it doesn’t seem to recognize the columns
(when I try to use ctrl space to show context sensitive help)

maybe I have to use this syntax to get to the column level ?:

iOrderDtl.Tables["OrderDtl"].Rows[i]["OrderLine"]

Could you show a snippet of your code that references a column from a table in your dataview ?

-------EDIT after some testing-----

Actually, using this approach my dataview is not getting passed, this is what my setup looks like:

Function parameter:
image

Network request:
(empty dataview, my order has 2 lines)
image

thanks

Hi Scott,
My function input parameter looks like this:
Name: GridTagRows Type: System.Data.DataSet

Inside the C# function code, I was able to get to the column as follows:

var tables = GridTagRows.Tables; // tablesSystem.Data.DataTableCollection
foreach (DataTable table in GridTagRows.Tables)
{
foreach (DataRow dr in table.Rows)
{
dumpGrid = dumpGrid + dr[“Character01”].ToString();
}
}

Hope this helps.
Mike

1 Like

ok, yes, that’s similiar to what I am doing,
this is my function signature:
image

But when I pass the OrderDtl view, the network request shows it’s empty (and my function trace tells me it;s null) :thinking:

and when I use Ctrl-Alt-V with debug tools (F12) OrderDtl is not empty and has 2 rows

Is your “GridTagRows” really a dataview ?

2 Likes

Have you solved it yet,I had the same problem!

1 Like

I did not solve it, but I found an alternate solution that is working for me.

When I get settled this morning I’ll type it up and post.

1 Like

I have a grid that is populated with a uBAQ the dataview for the grid is named “OFBMascotUP_0_0”.

User selects multiple rows to apply the same update, for example specify a date and then apply that to a date field on multiple rows in the grid. For this I have a button with an event:

image

for the function one of the parameters is ‘iJsonDS’
(input, JSON, dataset represented by a json string)

image

the sneaky part (found somewhere else on the forum) is the field value:
#_JSON.stringify(trans.dataView('OFBMascotUP_0_0').viewData)_#

the only part you would need to change is the view name, mine is “OFBMascotUP_0_0”

the code that handles iJsonDS in the function looks like this:

image

I’m parsing out 3 fields that I used in a DB table where clause lookup
(jobNum, assmSeq, oprSeq)
and one field that I use to determine if the row is one of them selected to be updated
(selected)
update selected rows then use Db.SaveChanges to apply the update to the database

then after the function completes I refresh the grid in the event with:
image

Hope that helps

2 Likes

Question, how did you send the selected row as a function parameter?

@Alvaro-Osorio

I have a calculated field in my BAQ that is just a boolean with a default value of false.

Then in properties for the grid, data/grid model/columns set that column to be the “Selector”

you also need to turn on “Selector Column” in data/grid model

The “Selector” property on the column ties the field to be the selector column,
If you don’t also mark it as hidden you will have two checkboxes to select rows

then when the Json dataset gets passed to the function you can parse out the value for the name of your calculated field, in my case “Calculated_Selected”

Hope that helps

4 Likes

Thanks, it worked perfectly for me.

3 Likes

Thank you for this!

I totally understand this but that datatype is not showing up. Is it that the modern/classic view of Epicor Functions Maintenance does not have it or is there something that has to be changed to allow a signature paramater of that type?

I am only getting - Date, String, Bool etc.

This would be a game changer. I can put a lot of our old UI code into functions and use it with little modification.

I’ve gotten functions to work - they arent new. But passing datasets is.

You need to scroll down the list.

1 Like

I was hoping to reply before I was outted. I figured it out and hit my forehead. Thank you all!

I got the same issue as the others though.

I pass the view but there is nothing in it (according to the function), which makes no sense. I can see the data on screen.

I figured it out by throwing an exception showing the count of the number of tables which was 0.

Update:
@datadaddy you are a genius, your solution worked. I made a proof of concept by throwing an exception showing all the part numbers in a dataview that was populated by a BAQ.

My function has a string parameter called JSONString

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

string results = "Starting";

foreach (var data in JSON_array)
{
   string partNum = (string)data["Part_PartNum"];
   results += "\n" + partNum;
   
}

Application Studio

I created a button , on click it calls a kinetic function, the function above

Method Parameters

Fieldname
JSONString

FieldValue
#JSON.stringify(trans.dataView(‘Parts For Label Printing’).viewData)#

I just tried it and it worked. Thank you kindly!

3 Likes

For the parts containing code related items you should pre and post fix the text with three successive backtics `

Here is helpful post on this: Code Syntax Highlighting in Posts

1 Like

I am using the CLASSIC Epicor screen when I use the Epicor Functions form (windows form, not browser).

The drop down for ‘Type’ has System.Data.DataSet. I am on version 2023.2.

Hope this helps. I am not sure what else to suggest.

1 Like

Sorry it should be

#_JSON.stringify(trans.dataView(‘Parts For Label Printing’).viewData)_#

My post is too old to edit.