Update existing record and not create a new one

Update existing record and not create a new one

Hi

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;
}
}

Appreciate the help!

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now