Epicor 10 Customzation

Ok so I am at a loss. I am currently working on duplicating records on a button click on a UD table. We have a very specific BAQ that we can not recreate inside of a data directive to use. So what I tried doing is using the BAQ and looping through to add the new records to the table. When someone adds these records to the table after they have saved. They will click a button to reference the BAQ with the parameters and add the correct amount of rows to the table. I have tried GetNew and GetaNew Methods, but they do not work unless the UI is cleared. Any help with this would be greatly appreciated. Below is a snippet of the code I am working with.

Thanks for you help.

private void CreateLotMapping()
{
	
		
		
	

				DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
				dqa.BOConnect();
				QueryExecutionDataSet ds = dqa.GetQueryExecutionParametersByID("AK_CHARPYMAP_01");
				ds.ExecutionParameter.Clear();
				ds.ExecutionParameter.AddExecutionParameterRow("JobNum",baqJobNum.Text,"nvarchar",false, Guid.NewGuid(),"A");
				ds.ExecutionParameter.AddExecutionParameterRow("HeatNum",baqHeat.Text,"nvarchar",false, Guid.NewGuid(),"A");
				ds.ExecutionParameter.AddExecutionParameterRow("LotNum",baqLot.Text,"nvarchar",false, Guid.NewGuid(),"A");
				dqa.ExecuteByID("AK_CHARPYMAP_01",ds);
				int count = ds.Tables["UD25"].Rows.Count;
				
	
				//Dataset
				foreach(DataRow rows in ds.Tables["UD25"].Rows)
				{

					UD25Adapter getnew = new UD25Adapter(UD25Form);
					getnew.BOConnect();
					Boolean test = getnew.GetaNewUD25();							
					edvUD25.dataView[edvUD25.Row]["Key3"] =  rows["LotNumber"].ToString();
					edvUD25.dataView[edvUD25.Row]["Key1"] = baqJobNum.Text;
					Boolean update = oTrans.Update();

				}



}

You mixed an outside adapter and then used the built-in adapter. Try this:

private void CreateLotMapping()
{
    DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
    dqa.BOConnect();
    QueryExecutionDataSet ds = dqa.GetQueryExecutionParametersByID("AK_CHARPYMAP_01");
    ds.ExecutionParameter.Clear();
    ds.ExecutionParameter.AddExecutionParameterRow("JobNum",baqJobNum.Text,"nvarchar",false, Guid.NewGuid(),"A");
    ds.ExecutionParameter.AddExecutionParameterRow("HeatNum",baqHeat.Text,"nvarchar",false, Guid.NewGuid(),"A");
    ds.ExecutionParameter.AddExecutionParameterRow("LotNum",baqLot.Text,"nvarchar",false, Guid.NewGuid(),"A");
    dqa.ExecuteByID("AK_CHARPYMAP_01",ds);
    int count = ds.Tables["UD25"].Rows.Count;
	
    //Dataset
    foreach(DataRow rows in ds.Tables["UD25"].Rows)
    {
        oTrans.GetaNewUD25();
        edvUD25.dataView[edvUD25.Row]["Key3"] =  rows["LotNumber"].ToString();
        edvUD25.dataView[edvUD25.Row]["Key1"] = baqJobNum.Text;
        //edvUD25.dataView[edvUD25.Row]["Key1"] = Guid.NewGuid(); //You may also need to create a unique ID...
        oTrans.Update();
    }
}
1 Like