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!
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方