Copy one tableset to another

,

I’m hoping this is an easy one. Is there a way to “clone” the tables/data from one tableset to another? For example, in a pre-processing method directive I have the ds that is the default tableset for that BPM. I have created my own version in a code block and pulled in some data and updated some rows. I now want to send the data from my tableset back to the default BPM tableset so that it gets picked up by the Update it’s already about to do.

Same type of Tableset?

You want to copy rows from one to the other, or just replace the whole thing?

Basically, I’ll take what I can get. I was hoping there was some high level tool that would just empty the existing tableset and re-fill it with the new one.

Like CTRL C / CTRL V code… :rofl:

1 Like

You’re in luck if the TableSet is the same and you want it replaced.

Like I know in SQL truncate and insert and so on… so I was hoping there was an equivalent for handling tables or tablesets in C#. I am sure I can muddle my way through deleting them one by one and re-adding them one by one but before I do that, I wanted to make sure there wasn’t an easier already established method that I didn’t know about.

DataSet.Copy?

DataSet.Copy Method (System.Data) | Microsoft Learn

That was my first thought but he did technically ask for Tableset… :smiley:

Update by query and then fill in the mappings??

Or am I missing what you are trying to do.

Excuse my ignorance… but is a dataset and a tableset the same thing? I know in Epicor I’m calling it a tableset but it’s called a ds in the method directive… so… yeah I don’t really know what the difference is if there is one.

They are different, but for most uses for us, they are the same.

Convert Erp.Tablesets to System.Data.DataSet - ERP 10 - Epicor User Help Forum (epiusers.help)

1 Like

You know, I tried that but I overlooked that my tables were in there. I just saw the tt tables and the ERP tables and I just assumed that was all I had. But yeah I think this would work.

If you have a dataset that needs to be returned from a bpm, and not a tableset you can use
this.dsHolder.Attach(ds); to attach your dataset instead.

What exactly are you working with?

I used that yesterday :slight_smile: Thanks @Olga lol

1 Like

I am working with UD100 and UD100A. When a record is updated in UD100A, I am checking all the child rows in UD100A and then updating a field in UD100 (a status). Only the rows I’m modifying show up in the ttUD100A in the ds in the method directive. So I am instantiating my own ds and doing a GetByID to pull in all the child rows. Then I can loop through them and check what I need to check to set my status on UD100. That part works fine. But my next step is that if the status is changed to “CLOSED”, then I need to fire off another BPM that does some stuff on the Sales Order BO and it involves the data in my ds for UD100A. However, I can’t pass that from one BPM to the next. So I figured if I could dump that back into the default ds, then I could do what I need to do in the next BPM because all my rows would be in there. I’m under the impression that as long as I don’t set the RowMod to U that the Update method will not do anything to the unchanged rows.

Is this in your 10 environment or 11 ?

10

Are all the records you need in the new tableset you made, and in the proper state?
If so, dsHolder.Attach is what you want.

If you need just to copy some rows from the one you made to the existing, you’ll have to do something different.

Something like this

  UD100Tableset yourTS = new UD100Tableset();
  
  var rowsToCopy = yourTS.UD100A.Where(x => x.Character01 == "Your Criteria Here")
                             .Select(x => x)
                             .ToList();

  
  ds.UD100A.AddRange(rowsToCopy);   //ttUD100A in yours ?