Trying to add Products from Accounts subform

Trying to add Products from Accounts subform

Hi, 

I have the following script to to add separate Products from a subform in an Account record. There is data in the subform, but I keep getting the error "No records were added". 

Please advise.


  1. string related_list.relateBuyerCriteria(String accountId)
  2. {
  3. // Convert accountId to string (if required by API)
  4. accountIdStr = accountId.toString();
  5. // Get the latest Account record from Zoho CRM
  6. formResponse = zoho.crm.getRecordById("Accounts",accountIdStr);
  7. if(formResponse.containsKey("Acquisition_Criteria"))
  8. {
  9. productList = formResponse.get("Acquisition_Criteria");
  10. successCount = 0;
  11. for each  product in productList
  12. {
  13. // Create a new related list entry in CRM
  14. productEntry = Map();
  15. productEntry.put("Account_Name",accountIdStr);
  16. productEntry.put("EBITDA",ifnull(product.get("EBITDA"),"N/A"));
  17. productEntry.put("Minimum_number_of_employees",ifnull(product.get("Minimum_number_of_employees"),"N/A"));
  18. productEntry.put("Minimum_number_of_years_in_business",ifnull(product.get("Minimum_number_of_years_in_business"),"N/A"));
  19. // Insert into the related list (Business_Wanted under Accounts)
  20. response = zoho.crm.createRecord("Business_Wanted",productEntry);
  21. // Check if insertion was successful
  22. if(response.containsKey("id"))
  23. {
  24. successCount = successCount + 1;
  25. }
  26. }
  27. if(successCount > 0)
  28. {
  29. return "Success: " + successCount + " related records added.";
  30. }
  31. else
  32. {
  33. return "No records were added.";
  34. }
  35. }
  36. else
  37. {
  38. return "No related records found.";
  39. }
  40. }


Thanks,

Jason