Zoho FSM | Create a Work Order in Zoho FSM from a Task in Zoho Desk

Create a Work Order in Zoho FSM from a Task in Zoho Desk

Usecase: Create a Work order in Zoho FSM whenever a Task is added in Zoho desk.
 

Step 1: Create a connection for Zoho FSM in Zoho Desk

To create a connection for Zoho FSM that can be used in Zoho Desk for invoking the Zoho FSM APIs, do the following:
  1. Navigate to Setup > Developer Space > Connections and click Create Connection.



  2. In the Create Connection page, select the Custom Services tab and click Create New Service.



  3. In the Create Service page, enter the following details and click Create Service.
    1. Service Name: Zoho FSM
      The Service Link Name will be automatically populated.
    2. Authentication Type: OAuth2
    3. Parameter Type: Header
    4. Generated Client IDClient Secret
    5. Authorize URL: https://accounts.zoho.com/oauth/v2/auth?access_type=offline&prompt=consent
    6. Access Token URL: https://accounts.zoho.com/oauth/v2/token
    7. Refresh Token URL: https://accounts.zoho.com/oauth/v2/token
    8. Scope: ZohoFSM.modules.all
      Provide values for Scope Display Name.



  4. Click Create Connection.



  5. Do the following and click Create And Connect:
    1. Connection Name: FSMConnection
    2. Select the Scopes ZohoFSM.modules.all



  6. Click Connect in the authentication page.



  7. Click Accept in the authorization page.


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

Step 2: Create a custom function

In Zoho Desk, create a custom function that will create a Work Order in Zoho FSM from a Task in Zoho Desk.
  1. Navigate to Setup > Automation > Workflows > Custom Functions and click New Custom Function.



  2. In the Configure Custom Function page, click Write your own.



  3. In the Add New Custom Function, do the following:
    1. Select the module Tasks
    2. Enter the Name as CreateWOInFSM
    3. Click Edit Arguments



  4. In the Edit Arguments overlay, enter the following and click Done:
    1. Method Name: CreateWOInFSM
    2. Name: task_id
    3. Value: Task Id



  5. Add the script below and click Save.

    try 
    {
    resp = zoho.desk.getRecordById("<OrgId>","tasks",task_id);
    ticket_id = resp.get("ticketId");
    ticket_resp = zoho.desk.getRecordById("<OrgId>","tickets",ticket_id);
    description = resp.get("subject");
    customer_email = ticket_resp.get("email");
    search_resp = invokeurl
    [
    type :GET
    connection:"fsmconnection"
    ];
    if(search_resp == "" || search_resp == null)
    {
    desk_contact_search_resp = zoho.desk.searchRecords("<OrgId>","Contacts",{"email":customer_email});
    desk_contact_search_data = desk_contact_search_resp.get("data").toMap();
    contact_create_Map = Map();
    contact_create_Map.put("Salutation","Mr.");
    contact_create_Map.put("First_Name",desk_contact_search_data.get("firstName"));
    contact_create_Map.put("Last_Name",desk_contact_search_data.get("lastName"));
    contact_create_Map.put("Email",desk_contact_search_data.get("email"));
    contact_create_Map.put("Phone",desk_contact_search_data.get("phone"));
    contact_create_Map.put("Mobile",desk_contact_search_data.get("mobile"));
    contact_Service_Address_Map = Map();
    contact_Service_Address_Map.put("Address_Name",desk_contact_search_data.get("lastName") + " Shipping Address");
    contact_Service_Address_Map.put("Street_1",desk_contact_search_data.get("street"));
    contact_Service_Address_Map.put("City",desk_contact_search_data.get("city"));
    contact_Service_Address_Map.put("State",desk_contact_search_data.get("state"));
    contact_Service_Address_Map.put("Zip_Code",desk_contact_search_data.get("zip"));
    contact_Service_Address_Map.put("Country",desk_contact_search_data.get("country"));
    contact_Billing_Address_Map = Map();
    contact_Billing_Address_Map.put("Address_Name",desk_contact_search_data.get("lastName") + " Billing Address");
    contact_Billing_Address_Map.put("Street_1",desk_contact_search_data.get("street"));
    contact_Billing_Address_Map.put("City",desk_contact_search_data.get("city"));
    contact_Billing_Address_Map.put("State",desk_contact_search_data.get("state"));
    contact_Billing_Address_Map.put("Zip_Code",desk_contact_search_data.get("zip"));
    contact_Billing_Address_Map.put("Country",desk_contact_search_data.get("country"));
    contact_create_Map.put("Service_Address",contact_Service_Address_Map);
    contact_create_Map.put("Billing_Address",contact_Billing_Address_Map);
    cr_resp = zoho.fsm.createRecord("Contacts",contact_create_Map);
    customer_id = cr_resp.get("data").toMap().get("Contacts").toMap().get("id");
    }
    else
    {
    customer_id = search_resp.get("data").toMap().get("id");
    }
    customer_resp = zoho.fsm.getRecordById("Contacts",customer_id);
    customer_data = customer_resp.get("data").toMap();
    Billing_Address_Map = customer_data.get("Billing_Address").toMap();
    if(Billing_Address_Map != null)
    {
    billing_Address_map = Map();
    billing_Address_map.put("id",Billing_Address_Map.get("id"));
    billing_Address_map.put("Billing_Street_1",Billing_Address_Map.get("Street_1"));
    billing_Address_map.put("Billing_Street_2",Billing_Address_Map.get("Street_2"));
    billing_Address_map.put("Billing_City",Billing_Address_Map.get("City"));
    billing_Address_map.put("Billing_State",Billing_Address_Map.get("State"));
    billing_Address_map.put("Billing_Country",Billing_Address_Map.get("Country"));
    billing_Address_map.put("Billing_Zip_Code",Billing_Address_Map.get("Zip_Code"));
    }
    Service_Address_Map = customer_data.get("Service_Address").toMap();
    if(Service_Address_Map != null)
    {
    service_Address_map = Map();
    service_Address_map.put("id",Service_Address_Map.get("id"));
    service_Address_map.put("Service_Street_1",Service_Address_Map.get("Street_1"));
    service_Address_map.put("Service_Street_2",Service_Address_Map.get("Street_2"));
    service_Address_map.put("Service_City",Service_Address_Map.get("City"));
    service_Address_map.put("Service_State",Service_Address_Map.get("State"));
    service_Address_map.put("Service_Country",Service_Address_Map.get("Country"));
    service_Address_map.put("Service_Zip_Code",Service_Address_Map.get("Zip_Code"));
    }
    Service_Line_Items_List = list();
    Service_Line_Items_Map = Map();
    servResp = zoho.fsm.getRecords("Service_And_Parts");
    service_id = servResp.get("data").toMap().get("id");
    Service_Line_Items_Map.put("Service",service_id);
    Service_Line_Items_Map.put("Quantity",1);
    Service_Line_Items_Map.put("Sequence",1);
    Service_Line_Items_Map.put("Contact",customer_id);
    Service_Line_Items_List.add(Service_Line_Items_Map);
    terrResp = zoho.fsm.getRecords("Territories");
    terrId = terrResp.get("data").toMap().get("id");
    createMap = Map();
    createMap.put("Summary",description);
    createMap.put("Contact",customer_id);
    createMap.put("Type","Service");
    createMap.put("Billing_Address",billing_Address_map);
    createMap.put("Service_Address",service_Address_map);
    createMap.put("Territory",terrId);
    createMap.put("Service_Line_Items",Service_Line_Items_List);
    response = zoho.fsm.createRecord("Work_Orders",createMap);
    info response;
    }
    catch (err)
    {
    sendmail
    [
    from :zoho.adminuserid
    to :zoho.adminuserid
    subject :"Error creating work order from task"
    message :err
    ]
    }
Replace <OrgId> with the actual value. To find the OrgId, in Zoho Desk, navigate to Setup > Developer Space > API. You will find the value under the heading Zoho Service Communication (ZSC) Key.
 

Step 3: Create a workflow rule

Create a workflow rule in Zoho Desk to create a Work order in Zoho FSM whenever a Task is added in Zoho desk.
  1. Navigate to Setup > Automation > Workflows and click Create Rule.



  2. In the New Workflow page, enter the following details and click Next.
    1. Module: Tasks
    2. Rule Name: CreateWOFromTask



  3. For Execute on, select Create and click Next.



  4. Skip Criteria and click Next.
  5. For Actions, select Custom Functions and click Existing.



  6. In the Associate Existing Custom Functions, select CreateWOInFSM.



  7. Click Save.

Testing the use case

Select a ticket in Zoho Desk and add a task under it.

 

 
A Work Order will be created in FSM.
 

 

    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

                                                                                                              • Create a Work Order in Zoho FSM from a Sales Order in Zoho Books

                                                                                                                Use case: Whenever a Sales Order 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 ...
                                                                                                              • 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 ...
                                                                                                              • Create a Work Order in Zoho FSM whenever a Subscription is created or renewed

                                                                                                                Use case: Whenever a subscription is created or renewed in Zoho Billing, create a Work Order in Zoho FSM. Step 1: Add a service named ForZBilling Step 2: Create a connection for Zoho FSM in Zoho Billing Step 3: Create a custom function in Zoho ...
                                                                                                              • Create a Work Order in FSM from a CRM Sales Order

                                                                                                                Use case: Create a work order in Zoho FSM whenever a sales order is created in Zoho CRM. Follow the steps below to implement this use case: Step 1: Create a connection for Zoho FSM in Zoho CRM Step 2: Create a workflow rule Step 3: Create a custom ...
                                                                                                              • 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 ...
                                                                                                                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