Create Requests in Zoho FSM from Zoho CRM Deals

Create Requests in Zoho FSM from Zoho CRM Deals

Usecase: Using custom button, push Deals in Zoho CRM as Requests in Zoho FSM. Also, create a related list in the Deals record that lists the requests created for the deal.
 

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 Space > Connections and click Create Connection.



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



  4. 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 ID, Client 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.



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



  7. Click Connect in the authentication page.



  8. 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 Links and Buttons tab and click New Button.



  3. In the Create Your Button page, do the following and click Save:
    1. What would you like to name the button?: CreateRequestInFSM
    2. Where would you like to place the button?: View Page
    3. What action would you like the button to perform?: Writing Function
      Create a custom function.

Step 3: Create a custom function 

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



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



  3. 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.



  4. Click Save.



  5. Add the script and click Save.

    dealResp = zoho.crm.getRecordById("Deals",deal_Id);
    if(dealResp != null)
    {
     Summary = dealResp.get("Deal_Name");
     /*
      Fetch Account related information
     */
     Account_Name = dealResp.get("Account_Name").toMap().get("name");
     Encoded_Account_Name = zoho.encryption.urlEncode(Account_Name);
     response = invokeurl
     [
      type :GET
      connection:"fsmconnection"
     ];
     // ADD IF ELSE HERE
     response_data = response.get("data").toMap();
     FSM_Account_id = response_data.get("id");
     /*
      Fetch Contact related information
     */
     Contact_Id = dealResp.get("Contact_Name").toMap().get("id");
     Contact_Resp = zoho.crm.getRecordById("Contacts",Contact_Id);
     Contact_Email = Contact_Resp.get("Email");
     responze = invokeurl
     [
      type :GET
      connection:"fsmconnection"
     ];
     // ADD IF ELSE HERE
     FSM_Contact_id = responze.get("data").toMap().get("id");
     Billing_Address_resp = responze.get("data").toMap().get("Billing_Address");
     if(Billing_Address_resp != null)
     {
      Billing_Address_resp = Billing_Address_resp.toMap();
      bill_add_map = Map();
      bill_add_map.put("id",Billing_Address_resp.get("id"));
      bill_add_map.put("Billing_City",Billing_Address_resp.get("City"));
      bill_add_map.put("Billing_Country",Billing_Address_resp.get("Country"));
      bill_add_map.put("Billing_Street_1",Billing_Address_resp.get("Street_1"));
      bill_add_map.put("Billing_State",Billing_Address_resp.get("State"));
      bill_add_map.put("Billing_Zip_Code",Billing_Address_resp.get("Zip_Code"));
      bill_add_map.put("Billing_Address_Name",Billing_Address_resp.get("Address_Name"));
     }
     Service_Address_resp = responze.get("data").toMap().get("Service_Address");
     if(Service_Address_resp != null)
     {
      Service_Address_resp = Service_Address_resp.toMap();
      ship_add_map = Map();
      ship_add_map.put("id",Service_Address_resp.get("id"));
      ship_add_map.put("Service_Street_1",Service_Address_resp.get("Street_1"));
      ship_add_map.put("Service_State",Service_Address_resp.get("State"));
      ship_add_map.put("Service_Zip_Code",Service_Address_resp.get("Zip_Code"));
      ship_add_map.put("Service_City",Service_Address_resp.get("City"));
      ship_add_map.put("Service_Country",Service_Address_resp.get("Country"));
      ship_add_map.put("Service_Address_Name",Service_Address_resp.get("Address_Name"));
     }
    }

    terrResp = zoho.fsm.getRecords("Territories");
    terrId = terrResp.get("data").toMap().get("id");

    createMap = Map();
    createMap.put("Summary",Summary);
    createMap.put("Contact",FSM_Contact_id);
    createMap.put("Company",FSM_Account_id);
    createMap.put("Service_Address",ship_add_map);
    createMap.put("Billing_Address",bill_add_map);
    createMap.put("Territory", terrId);
    create_resp = zoho.fsm.createRecord("Requests",createMap);
    reqId = create_resp.get("data").toMap().get("Requests").toMap().get("id");
    reqId = reqId + ",";
    dealResp = zoho.crm.getRecordById("Potentials",deal_Id);
    fieldVal = dealResp.get("Request_IDs");
    if(fieldVal != null)
    {
     reqId = reqId + fieldVal;
    }
    updateMap = Map();
    updateMap.put("Request_IDs",reqId);
    updateResp = zoho.crm.updateRecord("Potentials",deal_Id,updateMap);
    return "Function executed successfully";

Create a related list in the Deals record that lists the requests created for the deal.
  1. Navigate to a Deals record and click Add Related List.



  2. In the Add Related List popup, click Functions.



  3. In the Existing Functions popup, click Create New Function.



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



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



  6. 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.



  7. Click Save.



  8. Add the script and click Save.

    response = zoho.crm.getRecordById("Potentials",deal_Id);
    fieldVal = response.get("Request_IDs");
    products = fieldVal;
    productList = products.toList(",");
    responseXML = "";
    for each  productListItem in productList
    {
     rowVal = 0;
     url = "https://fsm.zoho.com/home#/tab/Requests/" + productListItem;
     responseXML = responseXML + "<row cnt='" + rowVal + "'><FL val='Request ID' link=\"true\" url=\"" + url + "\">" + productListItem + "</FL></row>";
     rowVal = rowVal + 1;
    }
    return responseXML;

  9. In the Create Custom Related List popup, click Save.

Testing the use case   

Click the CreateRequestInFSM button in a deals record.
Ensure the contact in the deal is already present in FSM. Use this custom function to push the contact from CRM to FSM.
 

 
A new Request will be created in FSM.
 

 
In the Deals record, the related list will be updated with the ID of the request created for this deal.



    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





                        Still can't find what you're looking for?

                        Write to us:  support@zohoforms.com


                                



                            





                          Manage your brands on social media




                              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

                                                                                          • Overview of Zoho FSM

                                                                                            What is Zoho FSM? Zoho FSM is a cloud application that offers an overarching solution for handling the entire life cycle of processes involved in the management and execution of field services. All processes that are pivotal to field services are ...
                                                                                          • Push Zoho CRM Contacts and Accounts to Zoho FSM

                                                                                            Usecase: Use custom buttons in Zoho CRM to do the following: Push (create/update) a Zoho CRM contact to Zoho FSM. If the contact has an associated account, create that account as a company in FSM. Push (create/update) a Zoho CRM account as a company ...
                                                                                          • Essentials of Zoho FSM

                                                                                            Key Terms Crew A crew consists of several field agents who are grouped together to conduct a specific task. Each crew is assigned a lead. Dispatch Console The scheduling tool from which the service appointments are scheduled and dispatched by users ...
                                                                                          • Zoho FSM Mobile App

                                                                                            The Zoho FSM mobile app empowers on-the-go field agents with all the information they need, to be efficient at work and delight contacts with every appointment. It helps them to be on time for their appointments, attend more appointments in a single ...
                                                                                          • Create a Request in Zoho FSM from your website

                                                                                            Usecase: Create a Request in Zoho FSM whenever user submits a form in your website. The user has to provide an email address of an existing Zoho FSM Contact. This can be achieved in Zoho FSM using the Create Request API. To do so, you need to follow ...
                                                                                          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