BufferCopy.Copy doesn't seems to work in Epicor Functions

I am passing a DataView to Epicor Function as an input parameter using rest-erp widget.
In Function type of input parameter is set to DataSet.
Now I need to copy DataRow to UD17Row.
I was trying to use BufferCopy.Copy as usually but it doesn’t work. Nothing is copied.

UD17Tableset inUD17ts = new UD17Tableset();

foreach (DataRow dr in inDS.Tables["UD17"].Rows)
{
  UD17Row rUD17 = new UD17Row();
  inUD17ts.UD17.Add(rUD17);
  BufferCopy.Copy<DataRow, UD17Row>(dr, rUD17);
}

I was also trying to use CopyDataTableToTSTable but the output was exactly the same. Nothing was copied.

Anyone succeed with copying from DataSet to TableSet using BufferCopy.Copy or CopyDataTableToTSTable?

@hmwillett

I found a workaround. It’s not a solution.
Because I was sending a Dataview based on UD17 Dataset, I changed a DataType in Function input parameter from DataSet to UD17Tableset.
With this change I avoided conversion from DataSet to Tableset (DataRow to UD17Row).

How do you know if BufferCopy.Copy worked or not?
There are other reasons the add may not have worked.

Serialize the data from both rows and pass back as a debug variable to get a look at it.

I suspect the RowMod is being overwritten.

1 Like

I added an output string variable to Function. I am filling variable with data from copied row. When my function is executed I can see value from variable in browser. All columns were empty…

Then the row structure must be different between the DataRow and the Ud17Row.

Maybe not the structure but DataType for columns with same names.

A DataRow is a different object to a UD17Row they don’t share many single level properties (BufferCopy is not a deep clone)

Also a Table set doesn’t generally have a Tables property how are you generating your InDS? Is that an incoming DataSet input into the function?

I don’t think Buffer Copy is going to work if that’s the case BufferCopy copies between identical properties and there probably won’t be any available

CopyDataTableToTSTable might have better luck but again only if the properties and comlumns match.

Yes.

Same story, different data type / properties and it doesn’t work.

As I wrote I changed input parameter from DataSet to UD17Tableset. Doing so I avoided conversion from DS to TS which was no longer needed.

1 Like