Pass connection to use for a function as a parameter

Pass connection to use for a function as a parameter

Hello,

I basically have a custom function that does some CRM queries on  a specific Lead ID.  I basically call in my custom function:

  1. zoho.crm.searchRecords(....., "THE_CRM_CONNECTION_TO_USE")

Since i have a production environment and several sandboxes to test things on and i would like to reuse those functions everywhere I tried to pass in instead of the connection string a variable that i would get as a parameter to the function. Every time i tried to do that upon hitting the save function button i get an error telling me that the connection i provided doesn't exist "although i haven't specified it yet as it will be specified with the function would run. Here is an example:
  1. // this works when i  pass in the predefined connection string literally.
    void function test_dynamic_connection(int id) {
          zoho.crm.getRecordById("Leads", id, Map(), "MY_PREDEFINED_CRM_CONNECTION");
    }

    // This doesn't work when i pass it dynamically
    void function test_dynamic_connection(int id, string connection) {
          zoho.crm.getRecordById("Leads", id, Map(), connection);
    }


My question would be if there is a way to pass the connection dynamically so i can share my custom functions between different sandboxes ( each with it's own connection) or not.

Thanks in advance.

Regards,
K. Mansour

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now