Zoho FSM | Email Customer the Service Reports along with the Invoices

Email Customer the Service Reports along with the Invoices

Usecase: When a service appointment is completed, email to the customer the service reports in the service appointment and the invoices in the parent work order.
 
Follow the steps below to implement this usecase:

Step 1: Create connections

Create a connection for Zoho FSM  

To use the FSM APIs via the invokeURL task in the custom function, you need to create a connection for FSM. To do so:
  1. Navigate to Setup > Developer Space > Connections and under Custom Services, and click Create Service.



  2. Enter the following details and click Create Service.
    1. Service Name: FSMCon
      The Service Link Name will be automatically populated.
    2. Authentication Type: OAuth2
    3. Parameter Type: Header
    4. Grant Type: Authorization Code
    5. Generated Client ID, Client Secret
    6. Authorize URL: https://accounts.zoho.com/oauth/v2/auth?access_type=offline&prompt=consent
    7. Access Token URL: https://accounts.zoho.com/oauth/v2/token
    8. Refresh Token URL: https://accounts.zoho.com/oauth/v2/token
    9. Scope: ZohoFSM.files.READ
      Provide a Scope Display Name.



  3. Click Create Connection.



  4. Perform the following and click Create And Connect:
    1. Connection Name: FSMCon
      The Connection Link Name will be populated automatically.
    2. Select the Scopes ZohoFSM.files.READ



  5. Click Connect.



  6. Click Accept.


In the custom function, where the FSM API is used via the invokeURL task, use this Connection Link Name.
 

Create a connection for Zoho Invoice

To use the Invoice APIs via the invokeURL task in the custom function, you need to create a connection for Invoice. To do so:
  1. Navigate to Setup > Developer Space > Connections and under Default Services, select Zoho Invoice.



  2. Click Create Connection.



  3. Perform the following and click Create And Connect:
    1. Connection Name: ZInvoice
      The Connection Link Name will be populated automatically.
    2. Select the Scopes ZohoInvoice.invoices.READ



  4. Click Connect.

    |

  5. Click Accept.

In the custom function, where the Invoice API is used via the invokeURL task, use this Connection Link Name.
 

System Connections

Additionally ensure that the status of the internal connections for Zoho FSM, and Zoho Invoice integration tasks are Connected. The green dot [] indicates that the connection is Connected.
 

Step 2: Create a custom function  

Create a custom function in Zoho FSM to email the customer the service reports of a service appointment and the invoices in the parent work order.
  1. Navigate to Setup > Automation > Functions and click Create Function.
  2. Enter the following details and click Save:
    1. Function Name: SendInvoiceAndSR
    2. Module: Service Appointments
    3. In the Deluge Script Editor, enter the following script:
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
  [
   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
]

Replace <orgId> with the actual value. To obtain the Organization ID, in Zoho Invoice, click the organization name at the top right corner and copy the Invoice Organization ID linked to your Zoho FSM account.


Step 3: Create a workflow rule  

Create a workflow rule in Zoho FSM to automatically email to the customer the service reports of a service appointment and the invoices in the parent work order when the service appointment is Completed.
  1. Go to Setup > Automation > Workflow Rules and click Create Workflow.
  2. Enter the following details, then click Next:
    1. Module: Service Appointments
    2. Rule Name: SendInvoiceAndSR
    3. Description: Email customer the service reports along with the invoice.



  3. Select the rule trigger as Edited and click Next.



  4. Select the rule criteria as Only to the Service Appointment matching certain conditions and add the condition Status is Completed. Click Next.



  5. Click +Action and select Function.



  6. Select Existing Functions and click Next.



  7. Select the custom function created in the previous step.



  8. Click Save.


Testing the usecase    

  1. Create a Service Appointment.
  2. Ensure that there is at least a Service Report added to the service appointment and an Invoice to the parent work order.
  3. Click Complete Work for the service appointment.
The service reports and invoices will be emailed to the contact in the service appointment.

    Access your files securely from anywhere

      Zoho CRM Training Programs

      Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

      Zoho CRM Training
        Redefine the way you work
        with Zoho Workplace

          Zoho DataPrep Personalized Demo

          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.

          Zoho CRM Training

            Create, share, and deliver

            beautiful slides from anywhere.

            Get Started Now


              Zoho Sign now offers specialized one-on-one training for both administrators and developers.

              BOOK A SESSION









                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                Manage your brands on social media

                                                  Zoho Desk Resources

                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                    Zoho Marketing Automation

                                                      Zoho Sheet Resources

                                                       

                                                          Zoho Forms Resources


                                                            Secure your business
                                                            communication with Zoho Mail


                                                            Mail on the move with
                                                            Zoho Mail mobile application

                                                              Stay on top of your schedule
                                                              at all times


                                                              Carry your calendar with you
                                                              Anytime, anywhere




                                                                    Zoho Sign Resources

                                                                      Sign, Paperless!

                                                                      Sign and send business documents on the go!

                                                                      Get Started Now




                                                                              Zoho TeamInbox Resources



                                                                                      Zoho DataPrep Resources



                                                                                        Zoho DataPrep Demo

                                                                                        Get a personalized demo or POC

                                                                                        REGISTER NOW


                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now









                                                                                                              • Related Articles

                                                                                                              • Service Reports

                                                                                                                A service report can be created for an appointment. It will capture the details of the service appointment, the associated contact details, and other inputs of customer acknowledgement such as signature, and rating. Available in Editions: All ...
                                                                                                              • Invoices

                                                                                                                The Invoices module helps you easily access all the invoices from a single place. You can create invoices, and make payments from here. Available in Editions: All Editions Create an Invoice - Permission Required: Invoices - Find out the ...
                                                                                                              • Creating Invoices

                                                                                                                To handle invoicing, and payments, Zoho FSM has built-in integration with Zoho Invoice. This will allow you to conveniently and quickly create invoices for your work orders and offer a secure way to your contacts to make payments. This means your ...
                                                                                                              • Send Service Report To Customer

                                                                                                                Usecase: Email the service report to the customer on service appointment completion. Follow the steps below to implement this usecase: Step 1: Create a connection for Zoho FSM Step 2: Create a custom function Step 3: Create a workflow rule Step 1: ...
                                                                                                              • Standard Reports

                                                                                                                Permission Required: Reports A report will only include data from records for which the user has View permission. List of Reports Select the Reports menu to view the following out-of-the-box FSM reports: Report Name Description Field Technicians - ...
                                                                                                                Wherever you are is as good as
                                                                                                                your workplace

                                                                                                                  Resources

                                                                                                                  Videos

                                                                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                  eBooks

                                                                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                  Webinars

                                                                                                                  Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                  CRM Tips

                                                                                                                  Make the most of Zoho CRM with these useful tips.



                                                                                                                    Zoho Show Resources