How Add a tableset CustShip.SelectedSerialNumbers a new row

Hello, I am creating a customer shipment, from the api rest, but when selecting the series of a part, I did not find how to create a new record in the tableset, previously it was:

foreach (SelectedSerialNumbersDataSet.SelectedSerialNumbersRow drr in ssds.SelectedSerialNumbers.Rows)
{
if (drr.SerialNumber == Series)
{
drr.RowMod = “A”;
csds.SelectedSerialNumbers.Rows.Add (drr.ItemArray);
}
}

I try with the tableset in the following way, without obtaining positive results

foreach (var drr in dSelected.SelectedSerialNumbers)
{
if (drr.SerialNumber == ds.Tables [0] .Rows [dr.OrderLine - 1] [“SerialNum”]. ToString ())
{
drr.RowMod = “A”;
cs.SelectedSerialNumbers.NewRow ();
cs.SelectedSerialNumbers.Add (drr);
}

                        }

Beforehand thank you very much

What errors are you getting. Also, more code to use for context would be helpful.

what is ds?
what is drr?

ds: it is a dataset that has the information of the client’s order, part, quantity, warehouse …

drr: it the row of Erp.Tableset.SelectedSerialNumbersTableset

cs: Erp.Tablesets.CustShipTableset.

I need create a new row in cs.SelectedSerialNumbers and that row is drr

You still didnt tell me what your error was, if I had to guess, it’s complaining when you try to add that row.

cs.SelectedSerialNumbers.NewRow (); has no effect other than adding a blank row, generally, you would assign that to a var to work on the actual row it creates like:
var newrow = cs.SelectedSerialNumbers.NewRow ();
newrow[“MyField”] = myValue;

In your case, it seems you are trying to add a row from a different table. Assuming they are identical types (cause this wont work otherwise), you will need to use cs.SelectedSerialNumbers.ImportRow(drr); Also, the NewRow() as mentioned earlier is not needed.

1 Like

Thk

this is the solution.

var drSNF = cs.SNFormat.NewRow();
drSNF[“Company”] = drSn.Company;
drSNF[“Plant”] = drSn.Plant;
drSNF[“PartNum”] = drSn.PartNum;
drSNF[“NumberOfDigits”] = drSn.NumberOfDigits;
drSNF[“SNBaseDataType”] = drSn.SNBaseDataType;
drSNF[“SNFormat”] = drSn.SNFormat;
drSNF[“LeadingZeroes”] = drSn.LeadingZeroes;
drSNF[“HasSerialNumbers”] = drSn.HasSerialNumbers;
drSNF[“SysRowID”] = drSn.SysRowID;
drSNF[“BitFlag”] = drSn.BitFlag;
drSNF[“PartPricePerCode”] = drSn.PartPricePerCode;
drSNF[“PartTrackLots”] = drSn.PartTrackLots;
drSNF[“PartTrackSerialNum”] = drSn.PartTrackSerialNum;
drSNF[“PartTrackDimension”] = drSn.PartTrackDimension;
drSNF[“PartSalesUM”] = drSn.PartSalesUM;
drSNF[“PartIUM”] = drSn.PartIUM;
drSNF[“PartSellingFactor”] = drSn.PartSellingFactor;
drSNF[“PartPartDescription”] = drSn.PartPartDescription;
drSNF[“SerialMaskMaskType”] = drSn.SerialMaskMaskType;
drSNF[“RowMod”] = “A”;
cs.SNFormat.Add(drSNF);

1 Like

Never mind, I figured it out by finding it in another post. So much for trying a quick and easy solution from anyone else who knows more than I do, which is most of the people on this site. See below:
var newsrl = arb.APSelectedRcptLines.NewRow();
newsrl[“Company”] = arb.APUninvoicedReceipts[0].Company;
newsrl[“RodMod”] = “A”;
arb.APSelectedRcptLines.Add(newsrl);
this.PublishInfoMessage(arb.APSelectedRcptLines[0].Company,Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"","");
Thanks,
Richard