Can anyone help with my code below. On form submission, it should check if a record with the same estimate number already exist. The Estimate_Number field is a look up field to another form (Client Info). The problem is that it is creating a new quote record with the same estimate number instead of updating the existing quote.
quoteRecord = Quotes[Estimate_Number == input.Estimate_Number];
rows = Collection();
if(quoteRecord.count(Estimate_Number) == 1)
{
for each rec in Quoted_Items
{
productinfo = Items_on_Quote2[Products == rec.Products];
productinfo.Client_Email=quoteRecord.ID;
productinfo.Products=rec.Products;
productinfo.Unit=rec.Unit;
productinfo.Unit2=rec.Unit2;
productinfo.Quantity=rec.Quantity;
productinfo.Description=rec.Description;
productinfo.Rate=rec.Rate;
productinfo.Amount=rec.Amount;
productinfo.Optional=rec.Optional;
productinfo.Opt_In=rec.Opt_In;
}
}