Hi Amit,
I have made something similar on our end. Slightly different as this is for a dashboard that allows you to edit the base price for a part across all price lists at the same time - however, the actual updating of the base price should be about the same!
Hopefully you can utilize some of my syntax on your end and get something working. Unfortunately, this was written when I was still learning the ropes and is quite messy, but contains all of the PriceLstService.Update syntax that you will require etc. I also handle creating a new entry from scratch within this code. I know that this is not a UBAQ, but consider using a function within Epicor Functions Maintenance for this use-case.
outputMsg = "";
string slideoutMsg = "";
decimal existingPrice = 0;
var ds = new Erp.Tablesets.PriceLstTableset();
bool skipTurn = false;
List<string> priceListOrder = new List<string>{
"Group1",
"Group1US",
"Group2",
"Group2US",
"Group3",
"Group3US",
"Group4",
"Group4US",
"Group5",
"Group6",
"Group6US",
"Group7",
"Group8",
"Group9",
"RushGroup4",
"TICOGrp3US",
"ZALTRCGrp4",
"ZBAYLYGrp3"
};
Dictionary<string, decimal> priceListGroups = new Dictionary<string, decimal>
{
{ "Group1", Math.Round(Group1, 2) },
{ "Group1US", Math.Round(Group1US, 2) },
{ "Group2", Math.Round(Group2, 2) },
{ "Group2US", Math.Round(Group2US, 2) },
{ "Group3", Math.Round(Group3, 2) },
{ "Group3US", Math.Round(Group3US, 2) },
{ "Group4", Math.Round(Group4, 2) },
{ "Group4US", Math.Round(Group4US, 2) },
{ "Group5", Math.Round(Group5, 2) },
{ "Group6", Math.Round(Group6, 2) },
{ "Group6US", Math.Round(Group6US, 2) },
{ "Group7", Math.Round(Group7, 2) },
{ "Group8", Math.Round(Group8, 2) },
{ "Group9", Math.Round(Group9, 2) },
{ "RushGroup4", Math.Round(RushGroup4, 2) },
{ "TICOGrp3US", Math.Round(TICOGrp3US, 2) },
{ "ZALTRCGrp4", Math.Round(ZALTRCGrp4, 2) },
{ "ZBAYLYGrp3", Math.Round(ZBAYLYGrp3, 2) }
};
this.CallService<Erp.Contracts.PriceLstSvcContract>(PriceLstService =>{
this.CallService<Erp.Contracts.PriceLstPartsSvcContract>(PriceLstPartsService =>{
for (int i = 0; i < priceListOrder.Count(); i++){
skipTurn = false;
slideoutMsg += "Group: " + priceListOrder[i] + " Value: " + priceListGroups[priceListOrder[i]] + "\n";
if (priceListGroups[priceListOrder[i]] <= 0){
slideoutMsg += "Skipping group, value <= 0.\n";
slideoutMsg += "\n";
continue;
}
try{
ds = new Erp.Tablesets.PriceLstTableset();
try{
var existingDataSet = PriceLstPartsService.GetByID(priceListOrder[i], PartNum, UOMCode);
if (existingDataSet.PriceLstParts.Any()){
foreach (var row in existingDataSet.PriceLstParts){
existingPrice = row.BasePrice;
if (existingPrice == priceListGroups[priceListOrder[i]]){
slideoutMsg += "Skipping group, value is equal to previous.\n";
slideoutMsg += "\n";
skipTurn = true;
break;
}
var newRow = ds.PriceLstParts.NewRow();
newRow["Company"] = row["Company"];
newRow["ListCode"] = row["ListCode"];
newRow["PartNum"] = PartNum; // override
newRow["BasePrice"] = priceListGroups[priceListOrder[i]]; // override
newRow["DiscountPercent1"] = row["DiscountPercent1"];
newRow["DiscountPercent2"] = row["DiscountPercent2"];
newRow["DiscountPercent3"] = row["DiscountPercent3"];
newRow["DiscountPercent4"] = row["DiscountPercent4"];
newRow["DiscountPercent5"] = row["DiscountPercent5"];
newRow["QtyBreak1"] = row["QtyBreak1"];
newRow["QtyBreak2"] = row["QtyBreak2"];
newRow["QtyBreak3"] = row["QtyBreak3"];
newRow["QtyBreak4"] = row["QtyBreak4"];
newRow["QtyBreak5"] = row["QtyBreak5"];
newRow["UnitPrice1"] = row["UnitPrice1"];
newRow["UnitPrice2"] = row["UnitPrice2"];
newRow["UnitPrice3"] = row["UnitPrice3"];
newRow["UnitPrice4"] = row["UnitPrice4"];
newRow["UnitPrice5"] = row["UnitPrice5"];
newRow["CommentText"] = row["CommentText"];
newRow["UOMCode"] = UOMCode; // override
newRow["GlobalPriceLstParts"] = row["GlobalPriceLstParts"];
newRow["GlobalLock"] = row["GlobalLock"];
newRow["CurrencyCode"] = row["CurrencyCode"];
newRow["CurrencyCodeCurrSymbol"] = row["CurrencyCodeCurrSymbol"];
newRow["DMTSysRowID"] = row["DMTSysRowID"];
newRow["ListCodeListDescription"] = row["ListCodeListDescription"];
newRow["PartDescription"] = row["PartDescription"];
newRow["PartNumIUM"] = row["PartNumIUM"];
newRow["PartNumPartDescription"] = row["PartNumPartDescription"];
newRow["PartNumPricePerCode"] = row["PartNumPricePerCode"];
newRow["PartNumSalesUM"] = row["PartNumSalesUM"];
newRow["PartNumSellingFactor"] = row["PartNumSellingFactor"];
newRow["PartNumTrackDimension"] = row["PartNumTrackDimension"];
newRow["PartNumTrackLots"] = row["PartNumTrackLots"];
newRow["PartNumTrackSerialNum"] = row["PartNumTrackSerialNum"];
newRow["PartPricePerCode"] = row["PartPricePerCode"];
newRow["PartSalesUM"] = row["PartSalesUM"];
newRow["PartSellingFactor"] = row["PartSellingFactor"];
newRow["RowMod"] = "U"; //Set rowmod to UPDATE
newRow["SellingFactorDirection"] = row["SellingFactorDirection"];
newRow["SysRevID"] = row["SysRevID"];
newRow["SysRowID"] = row["SysRowID"];
ds.PriceLstParts.Add(newRow);
}if (skipTurn){
continue;
}
PriceLstService.Update(ref ds);
slideoutMsg += "Updated. Original Price: " + Math.Round(existingPrice, 5) + " Changed To: " + priceListGroups[priceListOrder[i]] + "\n";
}else{
slideoutMsg += "Issue retrieving current values for this part. Please contact Connor with error for PriceLstPartsService.GetByID.\n";
}
}catch (Exception ex){
if (ex.Message.Contains("Record not found")){
PriceLstService.GetNewPriceLstParts(ref ds, priceListOrder[i], PartNum);
if (ds.PriceLstParts.Any()){
foreach (var part in ds.PriceLstParts){
part.BasePrice = priceListGroups[priceListOrder[i]];
part.PartNum = PartNum;
part.UOMCode = UOMCode;
part.RowMod = "A";
}
PriceLstService.Update(ref ds);
slideoutMsg += "Added to price list. No existing price found. Uploaded with price: " + priceListGroups[priceListOrder[i]] + "\n";
}else{
slideoutMsg += "Issue retrieving default values for PriceLstParts. Please contact Connor.\n";
}
}else{
slideoutMsg += "Please contact Connor with the following error.\n";
slideoutMsg += "Error: " + ex + "\n";
}
}
}catch (Exception ex){
if (outputMsg == ""){
outputMsg = "Errors Ecountered:\n";
}
outputMsg += "\nGroup: " + priceListOrder[i] + " Error: " + ex.Message;
}
slideoutMsg += "\n";
}
//DEBUGGING
debug = new DataSet();
DataTable priceLstPartsDataTable = new DataTable("PriceLstParts");
foreach (var column in ds.PriceLstParts.Columns)
{
priceLstPartsDataTable.Columns.Add(column.ColumnName, column.DataType);
}
foreach (var row in ds.PriceLstParts)
{
var dataRow = priceLstPartsDataTable.NewRow();
foreach (var column in ds.PriceLstParts.Columns)
{
dataRow[column.ColumnName] = row[column.ColumnName];
}
priceLstPartsDataTable.Rows.Add(dataRow);
}
debug.Tables.Add(priceLstPartsDataTable);
});
});
outputMsg += "\n" + slideoutMsg;
In my use-case, I have hard-coded all of the price list names (assuming you will have a parameter for which price list should be updated or query the associated price list from the customer associated with the quote for your solution)
My ‘Signature’ on the function to assist with readability:
References:


Hope this helps! I saw that you didn’t have an answer yet and wanted to share something similar from my end to hopefully assist
even if this isn’t using a UBAQ.