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