aptId = service_appointment.get("id"); response = zoho.fsm.getRecordById("Service_Appointments",aptId); service_appointment_resp = response.get("data").toMap(); relatedWOId = service_appointment_resp.get("Appointments_X_Services").toMap().get("Work_Order").get("id"); work_order_resp = zoho.fsm.getRecordById("Work_Orders",relatedWOId); woRespMap = work_order_resp.get("data").toMap(); serviceLineItems = woRespMap.get("Service_Line_Items").toList(); serviceLineItemsList = List(); file_attachment_list = List(); for each line_item in serviceLineItems { invoiceId = line_item.get("Invoice_Id"); if(invoiceId != null) { invoiceResp = zoho.fsm.getRecordById("Invoices",invoiceId); invoiceId1 = invoiceResp.get("data").toMap().get("ZBilling_InvoiceId"); invoiceResp1 = zoho.invoice.getRecordById("Invoices","<orgId>",invoiceId1); invoice_format = {"accept":"pdf"}; response = invokeurl [ url :"https://www.zohoapis.com/invoice/v3/invoices/" + invoiceId1 type :GET parameters:invoice_format connection:"zinvoice" ]; file_attachment_list.add(response); } } contact_id = service_appointment_resp.get("Contact").toMap().get("id"); contact_resp = zoho.fsm.getRecordById("Contacts",contact_id); contact_data = contact_resp.get("data").toMap(); Email = contact_data.get("Email"); srResp = zoho.fsm.getRelatedRecords("Service_Reports","Service_Appointments",aptId); if(srResp != null && srResp.containKey("data")) { relatedRecords = srResp.get("data").toList(); for each record in relatedRecords { reportpdfResp = record.get("Service_Report_PDF"); fileurl = reportpdfResp.get(0).get("download_Url"); fileResp = invokeurl [ url :"https://" + fileurl type :GET connection:"fsmcon" ]; file_attachment_list.add(fileResp); } } sendmail [ from :zoho.adminuserid to :Email subject :"Zoho FSM Service Reports and Invoices" message :"Please find attached the Service Reports and Invoices in service appointment." Attachments :file:file_attachment_list ] |
Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.
If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.
Write to us: support@zohoforms.com