Log calls with adding to activities by custom button and script (API 2.0)

Log calls with adding to activities by custom button and script (API 2.0)

There is no normal complete updated documentation and API 2.0 examples; now it is almost impossible to find the necessary answers. Therefore I will ask here.

It is necessary that when the button is pressed, the completed call is registered with auto-completion of fields, based on the available data.

We have already written a script that registers calls, but it does not list their activity-related lists of the module. That's what we did.

  1. contactDetails = zoho.crm.getRecordById("Contacts",contact_id.toLong());
  2. firstName = ifnull(contactDetails.get("First_Name"),"");
  3. lastName = ifnull(contactDetails.get("Last_Name"),"");
  4. contact_name = firstName + " " + lastName;
  5. owner_id = contactDetails.get("Owner").get("id");
  6. ctTime = zoho.currenttime.toString("yyyy-MM-dd'T'HH:mm:ss'+03:00'");
  7. out_call_log_obj = Map();
  8. out_call_log_obj.put("Subject","Вызов:" + " " + "⧀" + " " + contact_name);
  9. out_call_log_obj.put("Owner",owner_id);
  10. out_call_log_obj.put("Who_ID",contact_id.toLong());
  11. out_call_log_obj.put("Call_Type","Исходящий");
  12. out_call_log_obj.put("$se_module","Contacts");
  13. out_call_log_obj.put("Call_Start_Time",ctTime);
  14. out_call_log_obj.put("Call_Duration","5:00");
  15. out_call_log_obj.put("Who_id",contact_id.toLong());
  16. out_call_log_obj.put("$which_call","CompletedСall");
  17. add_out_resp = zoho.crm.create("Calls",out_call_log_obj);
  18. update_out_resp = zoho.crm.update("Contacts",contact_id.toLong(),contactDetails);
  19. info add_out_resp;
  20. info update_out_resp;
  21. return "Исходящий вызов добавлен успешно!";

How should I add a script so that calls are added to the list of activities associated with contacts?
Also interested in tasks and events.