getRecords - Avoid duplicates

getRecords - Avoid duplicates

Hello community, 

I'm maintaining  a Vendors table in creator, fetching data from Zoho Books. The vendor table can not contain duplicates for consistency in the records of my app. That's why I've checked the "No Duplicates" option on the contact_id fetched from Books. 

The issue now is that everythime I'm running the function to get records, I receive an error message because of finding duplicate values. How can I skip duplicates in the function below ?

Thanks a lot for your help. 

  1. void Get_Suppliers()
  2. {
  3. query_param = Map();
  4. query_param.put("contact_type","vendor");
  5. response = zoho.books.getRecords("vendors","00000","query_param","booksconnection");
  6. data = response.getJSON("contacts");
  7. for each  getdata in data
  8. {
  9. vendor_name = getdata.getJSON("vendor_name");
  10. contact_id = getdata.getJSON("contact_id");
  11. contact_type = getdata.getJSON("contact_type");
  12. insert into SUPPLIERS
  13. [
  14. SUPPLIER_NAME=vendor_name
  15. SUPPLIER_ID=contact_id
  16. CONTACT_TYPE=contact_type
  17. Added_User=zoho.loginuser
  18. ]
  19. }
  20. }

    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