Disable Use Credentials Of Login User. If this is disabled, the connection will utilize the credentials of the connection owner.
try { file_list = list(); Appointment_id = service_appointment.get("id"); service_appointment_resp = zoho.fsm.getRecordById("Service_Appointments",Appointment_id); service_appointment_map = service_appointment_resp.get("data").toMap(); contactId = service_appointment_map.get("Contact").get("id"); contactResp = zoho.fsm.getRecordById("Contacts",contactId); email = contactResp.get("data").toMap().get("Email"); service_related_resp = zoho.fsm.getRelatedRecords("Service_Reports","Service_Appointments",Appointment_id); //info service_related_resp; if(service_related_resp.isEmpty()) { info "No Service_Report added !!!"; } else { related_resp_list = service_related_resp.get("data"); for each each_related_resp in related_resp_list { service_report_map = each_related_resp.toMap(); Status = service_report_map.get("Status"); if(Status.equalsIgnoreCase("Draft")) { Service_Report_PDF = service_report_map.get("Service_Report_PDF").toMap(); Report_file_Id = Service_Report_PDF.get("file_Id"); fileResp = invokeurl [ url :"https://fsm.zoho.com/fsm/v1/files?file_id=" + Report_file_Id type :GET connection:"fsmcon" ]; filename = service_report_map.get("Name") + ".pdf"; fileResp.setFileType("pdf"); fileResp.setFileName(filename); // info fileResp; file_list.add(fileResp); } } } if(!file_list.isEmpty()) { sendmail [ from :zoho.adminuserid to :email subject :"Service Report with attachment" message :"PFA" Attachments :file:file_list ] } } catch (err) { info err; sendmail [ from :zoho.adminuserid to :zoho.adminuserid subject :"Error in executing the code" message :err ] } |