Morning
I'm trying to add existing products to a quote. I have the product number working fine it is just the unit of mesure id i'm having trouble with. the query i'm running is
QueryByAttribute queryun = new QueryByAttribute("uom");
query.AddAttributeValue("name", "Default Unit");
var unittype = service.RetrieveMultiple(queryun).Entities.FirstOrDefault();
The the outcome
Entity newQuoteproductsEntity = new Entity("quotedetail");
newQuoteproductsEntity["uomid"] = unittype.ToEntityReference();
When ever i run this i get the error
QueryByAttribute must specify a non-empty attribute array.
i have tried QueryByAttribute queryun = new QueryByAttribute("uomschedule");
with no joy. My question is how do i go about doing the above or can ichage the way i bring products into the quote and bring the whole product and all it's details. Below is the code i am using to pull the products i want
// Create a column set to define which attributes should be retrieved.
ColumnSet attributes = new ColumnSet(true);
Entity CurrentQuoteEntity = new Entity("quote");
var id = context.PrimaryEntityId;
CurrentQuoteEntity = service.Retrieve("quote", id, new ColumnSet("quoteid"));
//CurrentQuote.Get<EntityReference>(executionContext).Id, attributes);
Guid quoteid = CurrentQuoteEntity.Id;
// Create New Price List
Entity newquote = new Entity("quote");
newquote.Id = CurrentQuoteEntity.Id;
// newquote["MH900"] = MH900.Get<string>(executionContext);
service.Update(newquote);
decimal qant = 5m;
//return;
{
QueryByAttribute query = new QueryByAttribute("product");
query.AddAttributeValue("productnumber", "F0900H VMCSS RHD");
var product = service.RetrieveMultiple(query).Entities.FirstOrDefault();
QueryByAttribute queryun = new QueryByAttribute("uom");
query.AddAttributeValue("name", "Default Unit");
var unittype = service.RetrieveMultiple(queryun).Entities.FirstOrDefault();
// return;
Entity newQuoteproductsEntity = new Entity("quotedetail");
newQuoteproductsEntity["productid"] = product.ToEntityReference();
newQuoteproductsEntity["uomid"] = unittype.ToEntityReference();
newQuoteproductsEntity["quantity"] = qant;
newQuoteproductsEntity["quoteid"] = new EntityReference("quote", quoteid);
service.Create(newQuoteproductsEntity);
Kind Regards
*This post is locked for comments