id = service_appointment.get("id"); contactId = service_appointment.get("Contact").get("id"); contactResp = zoho.fsm.getRecordById("Contacts",contactId); email = contactResp.get("data").toMap().get("Email"); related_resp = zoho.fsm.getRelatedRecords("Notes","Service_Appointments",id); if(related_resp.isEmpty()) { info "No notes added !!!"; }else { related_resp_list = related_resp.get("data").toList(); for each each_related_resp in related_resp_list { each_related_resp_map = each_related_resp.toMap(); attachmentsResp = each_related_resp_map.get("$attachments"); if(attachmentsResp.isNull()){ info "No attachment present in the Note !!!"; }else{ attachments_list = each_related_resp_map.get("$attachments").toList(); for each attachment in attachments_list { file_id = attachment.get("$file_id"); fileResp = invokeurl [ url :"https://fsm.zoho.com/fsm/v1/files?file_id=" + file_id type :GET connection:"zfsm" ]; sendmail [ from :zoho.adminuserid to :email subject :"Zoho FSM Notes Attachments" message :"Please find attached the files in service appointment Notes." Attachments :file:fileResp ] } } } } |