Zoho FSM | Create Requests in Zoho FSM from Zoho CRM Deals

Create Requests in Zoho FSM from Zoho CRM Deals

Usecase: Using a custom button, push Deals in Zoho CRM as Requests to Zoho FSM.
 

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

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



  3. Under Default Services, choose Zoho FSM.



  4. Do the following and click Create And Connect:
    1. Connection Name: FSMConnection
    2. 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 FSM APIs are used via the invokeURL task, use this Connection Link Name.


Step 2: Create a custom button

Create a custom button in the Deals module to push a CRM Deal as a Request in FSM.
 
To create a custom button:
  1. Navigate to Setup > Customization > Modules and Fields and click the Deals module.



  2. Select the Buttons tab and click Create New Button.



  3. In the Create Custom Button page, do the following and click Save:
    1. Button Name: CreateRequestInFSM
    2. Define action: Function
    3. Select Page: In Record
    4. Select Position: Details
    5. Select Layout(s): Standard
    6. Configured Function: Click Choose and create a custom function.


Step 3: Create a custom function 

  1. In the Configure Function popup, select Write your own.



  2. In the Create New Function popup, enter the following and click Create.
    1. Function Name: CreateRequestInFSM
    2. Display Name: CreateRequestInFSM



  3. In the Deluge Script Editor, click Edit Arguments.



  4. In the Edit Arguments popup, do the following:
    1. Enter the argument name as deal_id.
    2. For the argument value, type # and select Deals - Deal Id and click Done.



  5. Click Save.



  6. Add the script. Click Save, then click Assosciate.

    string button.CreateRequestInFSM(String deal_id)
    {
    dealResp = zoho.crm.getRecordById("Deals",deal_id);
    Tax_Id = "5391129000000473001";
    // replace the TAX ID from the Books
    Tax_name = "us";
    // replace the TAX Name from the Books
    tax_percentage = 23;
    // replace the TAX Percentage from the Books
    tax = {"Taxable":true,"Tax_Percentage":tax_percentage,"Tax_Name":Tax_name,"Tax_Id":Tax_Id};
    erroravailable = false;
    errormessage = "";
    //info dealResp;
    if(dealResp != null)
    {
    Summary = dealResp.get("Deal_Name");
    Account = dealResp.get("Account_Name");
    AccountId = "";
    //info Account;
    if(Account != null && Account != "" && Account.containKey("id"))
    {
    AccountId = Account.get("id");
    Company_name = Account.get("name");
    //info AccountId;
    Account_resp = zoho.crm.getRecordById("Accounts",AccountId).toMap();
    Account_map = Account_resp.toMap();
    //info Account_map;
    Contact_Email = Account_map.get("Email");
    bl_address = Account_map.get("Billing_Street");
    bl_city = Account_map.get("Billing_City");
    bl_country = Account_map.get("Billing_Country");
    bl_state = Account_map.get("Billing_State");
    bl_zip = Account_map.get("Billing_Code");
    sh_address = Account_map.get("Shipping_Street");
    sh_city = Account_map.get("Shipping_City");
    sh_country = Account_map.get("Shipping_Country");
    sh_state = Account_map.get("Shipping_State");
    sh_zip = Account_map.get("Shipping_Code");
    }
    if(Company_name.toString() != "" && Company_name != null)
    {
    //info response;
    response = zoho.fsm.searchRecordsByField("Companies","ZCRM_Id",AccountId,Map(),"fsmconnection");
    info response;
    if(response.isNull() || response.isEmpty())
    {
    response = zoho.fsm.searchRecordsByField("Companies","Company_Name",Company_name,Map(),"fsmconnection");
    }
    //info response;
    if(response.toString() != "" && response != null)
    {
    list_item = response.get("data").get(0);
    serviceAdId = "";
    billingAdId = "";
    //info list_item;
    fsmCust = list_item.get("Company_Name");
    if(fsmCust.equalsIgnoreCase(Company_name))
    {
    fsm_Company_id = list_item.get("id");
    //info fsm_customer_id;
    Billing_Address = list_item.get("Billing_Address");
    Service_Address = list_item.get("Service_Address");
    if(Service_Address != null)
    {
    serviceAdId = Service_Address.get("id");
    }
    if(Billing_Address != null)
    {
    billingAdId = Billing_Address.get("id");
    }
    if(serviceAdId == "" && billingAdId != "")
    {
    serviceAdId = billingAdId;
    }
    else if(billingAdId == "" && serviceAdId != "")
    {
    billingAdId = serviceAdId;
    }
    else if(serviceAdId == "" && billingAdId == "")
    {
    Service_Address_Map = Map();
    Service_Address_Map.put("Address_Name",Company_name + " Shipping Address");
    Service_Address_Map.put("Street_1",sh_address);
    Service_Address_Map.put("City",sh_city);
    Service_Address_Map.put("State",sh_state);
    Service_Address_Map.put("Zip_Code",sh_zip);
    Service_Address_Map.put("Country",sh_country);
    Billing_Address_Map = Map();
    Billing_Address_Map.put("Address_Name",Company_name + " Billing Address");
    Billing_Address_Map.put("Street_1",bl_address);
    Billing_Address_Map.put("City",bl_city);
    Billing_Address_Map.put("State",bl_state);
    Billing_Address_Map.put("Zip_Code",bl_zip);
    Billing_Address_Map.put("Country",bl_country);
    response = zoho.fsm.updateRecord("Companies",fsm_Company_id,{"Service_Address":Service_Address_Map,"Billing_Address":Billing_Address_Map});
    con_response = zoho.fsm.getRecordById("Companies",fsm_Company_id).toMap();
    sample = con_response.get("data").get(0);
    if(sample.get("Service_Address") != null)
    {
    serviceAdId = sample.get("Service_Address").get("id");
    }
    if(sample.get("Billing_Address") != null)
    {
    billingAdId = sample.get("Billing_Address").get("id");
    }
    }
    }
    }
    else
    {
    Phone = Account_resp.get("Phone");
    createMap = Map();
    createMap.put("Company_Name",Company_name);
    createMap.put("Phone",Phone);
    createMap.put("Tax",tax);
    Service_Address_Map = Map();
    Service_Address_Map.put("Address_Name",Company_name + " Shipping Address");
    Service_Address_Map.put("Street_1",sh_address);
    Service_Address_Map.put("City",sh_city);
    Service_Address_Map.put("State",sh_state);
    Service_Address_Map.put("Zip_Code",sh_zip);
    Service_Address_Map.put("Country",sh_country);
    Billing_Address_Map = Map();
    Billing_Address_Map.put("Address_Name",Company_name + " Billing Address");
    Billing_Address_Map.put("Street_1",bl_address);
    Billing_Address_Map.put("City",bl_city);
    Billing_Address_Map.put("State",bl_state);
    Billing_Address_Map.put("Zip_Code",bl_zip);
    Billing_Address_Map.put("Country",bl_country);
    createMap.put("Service_Address",Service_Address_Map);
    createMap.put("Billing_Address",Billing_Address_Map);
    cr_resp = zoho.fsm.createRecord("Companies",createMap);
    fsm_Company_id = cr_resp.get("data").toMap().get("Companies").toMap().get("id");
    response = zoho.fsm.getRecordById("Companies",fsm_Company_id);
    //info response;
    billingAdId = response.get("data").toMap().get("Billing_Address").toMap().get("id");
    serviceAdId = response.get("data").toMap().get("Service_Address").toMap().get("id");
    }
    }
    Contact = dealResp.get("Contact_Name");
    //info Contact;
    Contact_Email = "";
    if(Contact != null && Contact != "" && Contact.containKey("id"))
    {
    Contact_id = Contact.get("id");
    Contact_name = Contact.get("name");
    //info AccountId;
    customer_resp = zoho.crm.getRecordById("Contacts",Contact_id).toMap();
    customer_map = customer_resp.toMap();
    Contact_Email = customer_map.get("Email");
    bl_address = customer_map.get("Billing_Street");
    bl_city = customer_map.get("Billing_City");
    bl_country = customer_map.get("Billing_Country");
    bl_state = customer_map.get("Billing_State");
    bl_zip = customer_map.get("Billing_Code");
    sh_address = customer_map.get("Shipping_Street");
    sh_city = customer_map.get("Shipping_City");
    sh_country = customer_map.get("Shipping_Country");
    sh_state = customer_map.get("Shipping_State");
    sh_zip = customer_map.get("Shipping_Code");
    //info customer_map;
    if(!Contact_id.isNull() && !Contact_id.isEmpty())
    {
    serviceAdId = "";
    billingAdId = "";
    response = zoho.fsm.searchRecordsByField("Contacts","ZCRM_Id",Contact_id,Map(),"fsmconnection");
    info response;
    if(response.isNull() || response.isEmpty())
    {
    if(!Contact_Email.isNull() && !Contact_Email.isEmpty())
    {
    response = zoho.fsm.searchRecordsByField("Contacts","Email",Contact_Email,Map(),"fsmconnection");
    }
    }
    //info response;
    if(response.toString() != "" && response != null)
    {
    list_item = response.get("data").get(0);
    serviceAdId = "";
    billingAdId = "";
    //info list_item;
    fsm_customer_id = list_item.get("id");
    Billing_Address = list_item.get("Billing_Address");
    Service_Address = list_item.get("Service_Address");
    if(Service_Address != null)
    {
    serviceAdId = Service_Address.get("id");
    }
    if(Billing_Address != null)
    {
    billingAdId = Billing_Address.get("id");
    }
    if(serviceAdId == "" && billingAdId != "")
    {
    serviceAdId = billingAdId;
    }
    else if(billingAdId == "" && serviceAdId != "")
    {
    billingAdId = serviceAdId;
    }
    else if(serviceAdId == "" && billingAdId == "")
    {
    Service_Address_Map = Map();
    Service_Address_Map.put("Address_Name",Contact_name + " Shipping Address");
    Service_Address_Map.put("Street_1",sh_address);
    Service_Address_Map.put("City",sh_city);
    Service_Address_Map.put("State",sh_state);
    Service_Address_Map.put("Zip_Code",sh_zip);
    Service_Address_Map.put("Country",sh_country);
    Billing_Address_Map = Map();
    Billing_Address_Map.put("Address_Name",Contact_name + " Billing Address");
    Billing_Address_Map.put("Street_1",bl_address);
    Billing_Address_Map.put("City",bl_city);
    Billing_Address_Map.put("State",bl_state);
    Billing_Address_Map.put("Zip_Code",bl_zip);
    Billing_Address_Map.put("Country",bl_country);
    response = zoho.fsm.updateRecord("Contacts",fsm_customer_id,{"Service_Address":Service_Address_Map,"Billing_Address":Billing_Address_Map});
    //info response;
    con_response = zoho.fsm.getRecordById("Contacts",fsm_customer_id).toMap();
    sample = con_response.get("data").get(0);
    if(sample.get("Service_Address") != null)
    {
    serviceAdId = sample.get("Service_Address").get("id");
    }
    if(sample.get("Billing_Address") != null)
    {
    billingAdId = sample.get("Billing_Address").get("id");
    }
    }
    }
    else
    {
    Phone = customer_resp.get("Phone");
    createMap = Map();
    createMap.put("Last_Name",Contact_name);
    createMap.put("Email",Contact_Email);
    createMap.put("Phone",Phone);
    createMap.put("Tax",tax);
    Service_Address_Map = Map();
    Service_Address_Map.put("Address_Name",Contact_name + " Shipping Address");
    Service_Address_Map.put("Street_1",sh_address);
    Service_Address_Map.put("City",sh_city);
    Service_Address_Map.put("State",sh_state);
    Service_Address_Map.put("Zip_Code",sh_zip);
    Service_Address_Map.put("Country",sh_country);
    Billing_Address_Map = Map();
    Billing_Address_Map.put("Address_Name",Contact_name + " Billing Address");
    Billing_Address_Map.put("Street_1",bl_address);
    Billing_Address_Map.put("City",bl_city);
    Billing_Address_Map.put("State",bl_state);
    Billing_Address_Map.put("Zip_Code",bl_zip);
    Billing_Address_Map.put("Country",bl_country);
    createMap.put("Service_Address",Service_Address_Map);
    createMap.put("Billing_Address",Billing_Address_Map);
    cr_resp = zoho.fsm.createRecord("Contacts",createMap);
    //info cr_resp;
    fsm_customer_id = cr_resp.get("data").toMap().get("Contacts").toMap().get("id");
    response = zoho.fsm.getRecordById("Contacts",fsm_customer_id);
    //info response;
    billingAdId = response.get("data").toMap().get("Billing_Address").toMap().get("id");
    serviceAdId = response.get("data").toMap().get("Service_Address").toMap().get("id");
    }
    terrResp = zoho.fsm.getRecords("Territories");
    terrId = terrResp.get("data").toMap().get("id");
    createMap = Map();
    createMap.put("Summary",Summary);
    createMap.put("Company",fsm_Company_id);
    createMap.put("Contact",fsm_customer_id);
    createMap.put("Service_Address",{"id":serviceAdId});
    createMap.put("Billing_Address",{"id":billingAdId});
    createMap.put("Territory",terrId);
    info createMap;
    }
    }
    else
    {
    erroravailable = true;
    errormessage = "Contacts is Mandatory for workorder creation";
    }
    }
    if(erroravailable == false)
    {
    create_resp = zoho.fsm.createRecord("Requests",createMap);
    reqId = create_resp.get("data").toMap().get("Requests").toMap().get("id");
    api_url = "https://fsm.zoho.com/fsm/v1/Requests/" + reqId + "/actions/process_sync?sync_service=zohocrm";
    // Update the link to the based on the DC.
    // Define the body
    request_body = Map();
    data_list = List();
    data_item = Map();
    data_item.put("integ_id",deal_id);
    data_item.put("sync_process","link");
    data_item.put("integ_module","Deals");
    data_list.add(data_item);
    request_body.put("data",data_list);
    // Convert the body to JSON string
    request_body_json = request_body.toString();
    link_res = invokeurl
    [
    url :api_url
    type :POST
    parameters:request_body_json
    connection:"fsmconnection"
    ];
    }
    else
    {
    info errormessage;
    /* sendmail
        [
        from: zoho.adminuserid
        to: zoho.adminuserid
        subject: "Request is not created"
        message: errormessage
       
        ] */
    }
    return "Function executed successfully";
    }

Testing the use case

Click the CreateRequestInFSM button in a deals record.
Ensure the contact in the deal is already present in Zoho FSM and also that the has a service address and billing address. Use this custom function to push the contact from CRM to FSM.


 
A new Request will be created in Zoho FSM. The link to the deal will be available in the request.



The requests created for the deal will be listed under the Zoho FSM related list.



      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        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 LinksWorkflow AutomationData Collection
                              Web FormsRetailOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceForms for Solopreneurs
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit
                              Forms for Government
                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic FormsInsurance
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsWufoo alternativeEncrypted Forms
                              Accessible FormsTypeform alternativeSecure Forms

                              WCAG

                                          Create. Review. Publish.

                                          Write, edit, collaborate on, and publish documents to different content management platforms.

                                          Get Started Now






                                                            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

                                                                  Use cases

                                                                  Make the most of Zoho Desk with the use cases.

                                                                   
                                                                    

                                                                  eBooks

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

                                                                   
                                                                    

                                                                  Videos

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

                                                                   
                                                                    

                                                                  Webinar

                                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                                   
                                                                    
                                                                  • Desk Community Learning Series


                                                                  • Meetups


                                                                  • Ask the Experts


                                                                  • Kbase


                                                                  • Resources


                                                                  • Glossary


                                                                  • Desk Marketplace


                                                                  • MVP Corner



                                                                    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 Demo

                                                                                                      Get a personalized demo or POC

                                                                                                      REGISTER NOW


                                                                                                        Design. Discuss. Deliver.

                                                                                                        Create visually engaging stories with Zoho Show.

                                                                                                        Get Started Now










                                                                                                                            • Related Articles

                                                                                                                            • Integrating Zoho FSM with Zoho CRM

                                                                                                                              Zoho FSM for Zoho CRM is a must-have extension for increasing collaboration between your sales and service teams. It can benefit the sales and service teams by providing them with a consolidated view of customers, enabling quicker and more efficient ...
                                                                                                                            • Who can create Requests in Zoho FSM?

                                                                                                                              In Zoho FSM, Requests can be created by users with profiles such as Administrators, Dispatchers, Call Center Agents, Field Agents or any custom profile that has the permission to create Requests.
                                                                                                                            • Zoho FSM Extension for Zoho CRM (Direct Data Sync)

                                                                                                                              Prerequisites - Standard edition or above of Zoho FSM - Standard edition or above of Zoho CRM - Zoho CRM is not integrated with a Zoho Finance Suite (Books/Invoice) org In Zoho FSM, navigate to Setup > Integration > Zoho CRM and click Integrate Zoho ...
                                                                                                                            • Requests

                                                                                                                              Requests are initiated to render services to customers. Services are the offerings you provide as part of your field services. Customers can contact a call center agent to raise the request on their behalf. You can create requests from the Zoho FSM ...
                                                                                                                            • Zoho FSM Extension for Zoho CRM (Data Sync via Zoho Books/Invoice)

                                                                                                                              Prerequisites - Standard edition or above of Zoho FSM - Standard edition or above of Zoho CRM Install the Extension You can install Zoho FSM for Zoho CRM either from Zoho Marketplace or from Zoho CRM. To install the extension from your Zoho CRM ...
                                                                                                                              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