Zoho FSM | Automate creating and sending Invoice on work order creation

Automate creating and sending Invoice on work order creation

Usecase: When creating a work order, based on an user input, automatically create and send invoice for the work order.
 
Follow the steps below to implement this usecase:

Step 1: Create a custom field

Create a custom field Create and Send Invoice of type checkbox in the Work Orders module. If the user selects this checkbox, then the invoice should be automatically created and sent for the work order.
 

Step 2: 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 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.modules.all
      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. Disable Use Credentials Of Login User.
    3. Select the Scopes ZohoFSM.modules.all



  5. Click Connect in the authentication page.



  6. Click Accept in the Authorization page.


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

Step 3: Create a custom function

Create a custom function in Zoho FSM to create and send invoice for a work order
  1. Navigate to Setup > Automation > Functions and click Create Function.
  2. Enter the following details and click Save:
    1. Function Name: CreateAndSendInvoice
    2. Module: Work Order
    3. In the Deluge Script Editor, enter the following script:

      Work_Order_Id = work_order.get("id");
      Service_Line_Items = work_order.get("Service_Line_Items");
      line_item_id_list = list();
      for each  Service_Line_Item in Service_Line_Items
      {
       line_item_id = Service_Line_Item.toMap().get("id");
       line_item_id_list.add(line_item_id);
      }
      data = {"data":{{"Work_Order":Work_Order_Id,"$Service_Line_Items":line_item_id_list,"$finance_data":{"discount_preference":{"Adjustment":0}}}}};
      invoice_response = invokeurl
      [
       type :POST
       parameters:data.toString()
       connection:"fsmcon"
      ];
      info "invoice_response: " + invoice_response;
      invoice_id = invoice_response.get("data").toMap().get("Invoices").toMap().get("id");
      contact_id = work_order.get("Contact").toMap().get("id");
      contactResp = zoho.fsm.getRecordById("Contacts",contact_id);
      contactData = contactResp.get("data").toMap();
      email = contactData.get("Email");
      email_list = list();
      email_list.add(email);
      invoice_data = {"data":{"send_invoice_pdf":true,"to_mail_ids":email_list,"send_from_org_email_id":true}};
      send_invoice_response = invokeurl
      [
       url :"https://fsm.zoho.com/fsm/v1/Invoices/" + invoice_id + "/actions/send_invoice"
       type :POST
       parameters:invoice_data.toString()
       connection:"fsmcon"
      ];
      info send_invoice_response;

Step 4: Create a workflow rule

Create a workflow rule in Zoho FSM to automatically create and send invoice for a work order when the user selects the checkbox Create and Send Invoice in the work order.
  1. Go to Setup > Automation > Workflow Rules and click Create Workflow.
  2. Enter the following details, then click Next:
    1. Module: Work Orders
    2. Rule Name: CreateAndSendInvoice
    3. Description: When the user selects the checkbox Create and Send Invoice in the work order, automatically create and send invoice.



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



  4. Select the rule criteria as Only to the Work Order matching certain conditions and add the condition Create and Send Invoice is Selected. 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

Create a Work Order. Ensure the checkbox Create and Send Invoice is selected.
 

 
The invoice will be automatically created for the work order and sent to the customer.
 


    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





                          Quick Links Workflow Automation Data Collection
                          Web Forms Enterprise Begin Data Collection
                          Interactive Forms Workplace Data Collection App
                          CRM Forms Customer Service Accessible Forms
                          Digital Forms Marketing Forms for Small Business
                          HTML Forms Education Forms for Enterprise
                          Contact Forms E-commerce Forms for any business
                          Lead Generation Forms Healthcare Forms for Startups
                          Wordpress Forms Customer onboarding Order Forms for Small Business
                          No Code Forms Construction RSVP tool for holidays
                          Free Forms Travel
                          Prefill Forms Non-Profit

                          Intake Forms Legal
                          Mobile App
                          Form Designer HR
                          Mobile Forms
                          Card Forms Food Offline Forms
                          Assign Forms Photography
                          Mobile Forms Features
                          Translate Forms Real Estate Kiosk in Mobile Forms
                          Electronic Forms

                          Notification Emails for Forms Alternatives Security & Compliance
                          Holiday Forms Google Forms alternative  GDPR
                          Form to PDF Jotform alternative HIPAA Forms
                          Email Forms
                          Encrypted Forms
                          Embeddable Forms
                          Secure Forms
                          Drag and Drop form builder
                          WCAG


                                            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

                                                                                                              • Work Orders

                                                                                                                A work order is a record created for executing a contact service request. Available in Editions: All Editions Create Work Orders Permission Required: Work Orders A Work Order can be created in one of the following ways: From Requests: Use the Convert ...
                                                                                                              • 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 ...
                                                                                                              • Create an Estimate in Zoho Invoice from a Work Order in Zoho FSM

                                                                                                                Use case: Whenever a Work Order is created in Zoho FSM, create an Estimate for it in Zoho Invoice. Follow the steps below to implement this use case: Step 1: Create a custom function Step 2: Create a workflow rule Step 1: Create a custom function ...
                                                                                                              • Create a Work Order in Zoho FSM from an Invoice in Zoho Books

                                                                                                                Use case: Whenever an Invoice is created in Zoho Books, create a Work Order for it in Zoho FSM. Follow the steps below to implement this use case: Step 1: Create a connection for Zoho FSM in Zoho Books Step 2: Create a custom function in Zoho Books ...
                                                                                                              • Calculate Work Order Profit

                                                                                                                Use case: Calculate the profit earned for a work order. Profit = Grand Total of the work order - Total cost price of the work order where, Total cost price of the work order = Total cost price of the services used + Total cost price of the parts used ...
                                                                                                                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