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.
- string related_list.relateBuyerCriteria(String accountId)
- {
- // Convert accountId to string (if required by API)
- accountIdStr = accountId.toString();
- // Get the latest Account record from Zoho CRM
- formResponse = zoho.crm.getRecordById("Accounts",accountIdStr);
- if(formResponse.containsKey("Acquisition_Criteria"))
- {
- productList = formResponse.get("Acquisition_Criteria");
- successCount = 0;
- for each product in productList
- {
- // Create a new related list entry in CRM
- productEntry = Map();
- productEntry.put("Account_Name",accountIdStr);
- productEntry.put("EBITDA",ifnull(product.get("EBITDA"),"N/A"));
- productEntry.put("Minimum_number_of_employees",ifnull(product.get("Minimum_number_of_employees"),"N/A"));
- productEntry.put("Minimum_number_of_years_in_business",ifnull(product.get("Minimum_number_of_years_in_business"),"N/A"));
- // Insert into the related list (Business_Wanted under Accounts)
- response = zoho.crm.createRecord("Business_Wanted",productEntry);
- // Check if insertion was successful
- if(response.containsKey("id"))
- {
- successCount = successCount + 1;
- }
- }
- if(successCount > 0)
- {
- return "Success: " + successCount + " related records added.";
- }
- else
- {
- return "No records were added.";
- }
- }
- else
- {
- return "No related records found.";
- }
- }
Thanks,
Jason