Hi all
I was working on and create and update workflow plugin and seem to have run into an issue of the plugin not finding the productpricelevel i thought i had matched the correct entity id but not convinced now. I think it's looking at the actual price list id. any guidance would be helpful. Below is a condensed section of the plugin and where the issue i believe must lie and think the main suspect to be the following line
newProductPriceLevelEntity.Id = newPriceLevel.Id;
// Get current product price level
QueryExpression productPriceLevelExpression = new QueryExpression("productpricelevel");
FilterExpression productPriceLevelFilterExpression = new FilterExpression();
productPriceLevelFilterExpression.Conditions.Add(new ConditionExpression("pricelevelid", ConditionOperator.Equal, currentPriceLevelEntity["pricelevelid"]));
productPriceLevelExpression.ColumnSet = new ColumnSet(true);
productPriceLevelExpression.Criteria = productPriceLevelFilterExpression;
EntityCollection productPriceLevelList = service.RetrieveMultiple(productPriceLevelExpression);
// Update new product price level records
for (int index = 0; productPriceLevelList.Entities != null && index < productPriceLevelList.Entities.Count; index++)
{
Entity newProductPriceLevelEntity = new Entity("productpricelevel");
newProductPriceLevelEntity["pricelevelid"] = new EntityReference("pricelevel", newPriceLevel.Id);
newProductPriceLevelEntity["productid"] = productPriceLevelList.Entities[index]["productid"];
newProductPriceLevelEntity["productnumber"] = productPriceLevelList.Entities[index]["productnumber"];
newProductPriceLevelEntity["uomid"] = productPriceLevelList.Entities[index]["uomid"];
string prodidse = Convert.ToString(newProductPriceLevelEntity["productnumber"]);
newProductPriceLevelEntity.Id = newPriceLevel.Id;
//900 ring price makeup
if (prodidse == "F0900 TAG VMHS F")
{
costamount = price900int;
goto endt;
}
else if (prodidse == "F0900 TAG VMHS T")
{
costamount = price900int / 4 * 3;
goto endt;
}
else if (prodidse == "F3000 TAG SOAKRTR")
{
costamount = price3000int / 4 / 100 * 200 + (Soakawayint * 27) + (steppriceint * 3);
goto endt;
}
else if (prodidse == "F3000 TAG SOAKRHR")
{
costamount = price3000int / 4 / 100 * 200 + (Soakawayint * 18) + (steppriceint * 2);
goto endt;
}
else
{
costamount = 0;
;
}
endt:
newProductPriceLevelEntity["amount"] = new Money(costamount);
service.Update(newProductPriceLevelEntity);
Many Thanks
Dan