Install Actions

Install Actions

This guide helps you with the following:

  1. Create a post install script
    1. InstallParamMap variable 
    2. Example 
  2. Create a post uninstall script 
  3. Create an on authorization script for connectors 
    1. Example
  4. Create an on revoke script for connectors 
    1. Example
  5. Execute a script on purchase 
    1. UpgradeMap Variable 
    2. Example
  6. Execute a script on plan downgrade 
    1. DowngradeMap variable 
    2. Example 
Sometimes, you might want your extension to run a customized script immediately after installation or upgradation. For example, you might want to create sample data, or send an email notification about the installation to the CRM users or to an external system, or kick off a batch operation to populate a new field across a large set of data. This cannot be achieved with the help of a custom function or workflow rules. To help you achieve this, Zoho Developer allows you to bundle a post install script along with your extension.

The post install scripts are small snippets of codes or commands that are to be executed immediately after the extension is installed or updated.

Create a post install script

To add a post install script to your extension
  1. Log in to your Zoho Developer console and click Extensions for Zoho CRM.
  2. Select the extension you'd like to modify and click Edit.
  3. Select Install Actions in the left pane.
  4. Select Extension and click On Installation.
  5. In the Deluge Script Editor, write the required code.
  6. Click Save and Execute if you want to test your code or else simply click Save.



Note
  1. You can write only one post install script per extension.
  2. The post install script gets triggered automatically when the extension is installed or updated.
  3. This script can be triggered only once.

InstallParamMap Variable

The installParamMap variable can be used only with the post install script and is used to obtain the following data from Zoho CRM:
      1. Organization ID - The unique Organization ID of the Zoho CRM account in which the extension is installed. The syntax to obtain the org ID is 
  1. <variable_name>= input.installParamMap.get("organizationId");
      2. Installer ID - The unique ID of the user who installs the extension. The syntax to obtain the installer ID is
  1. <variable_name>= input.installParamMap.get("installerId");
      3. IsInstall - This is used to check whethere the extension is installed for the first time or is an upgradation. The syntax for this task is
  1. <variable_name>= input.installParamMap.get("isInstall");
      4. PreviousVersion - The value of the previous version of the extension in case of an update. The syntax to obtain the previous version number is
  1. <variable_name>= input.installParamMap.get("previousVersion");
 
Example
Consider the following scenario, A user who installs your extension wishes to alert all the other users in the CRM system about the installation via an email. This can be achieved with the help of a simple post install script.
  1. orgid = input.installParamMap.get("organizationId");
  2. installerid = input.installParamMap.get("installerId");
  3. isInstall = input.installParamMap.get("isInstall");
  4. pversion = input.installParamMap.get("previousVersion");
  5. sendmail
  6. (
  7. To       :  zoho.adminuserid
  8. From     :  zoho.adminuserid
  9. Subject  :  "Post Install script executed"
  10. Message  :  "Installation details ---> OrgId = " + orgid + " : Installer Id = " + installerid + " : is Install = " + isInstall + " : previous version = " + pversion
  11. )

This script when executed, sends an email to admin of the CRM system with the details of the extension and the user who installed the extension.
Similarly you can perform any action using the post installer script.
 

Create a post uninstall script

To create a post-uninstall script
  1. Log in to your Zoho Developer console and click Extensions for Zoho CRM.
  2. Select the extension you'd like to modify and click Edit.
  3. Select Install Actions in the left pane.
  4. Select Extension and click On Uninstallation.
  5. In the Deluge Script Editor, write the required code.
  6. Click Save and Execute if you want to test your code or else simply click Save.
  7. Publish the extension again to make this change effective.

Create an on authorization script for connectors

Occasionally, you might want to run a customized script immediately after a connector has been authorized. For example, you might want to register webhooks or create users. These objectives cannot be achieved with a custom function or workflow rules. To help you achieve this, Zoho Developer allows you to create an add-on script that will get executed post authorization of the connector.

The post authorization script is a snippet of code or command that is to be executed after authorization of the connector.

To include a post authorization script for a connector:
  1. Click Extensions for Zoho CRM in the Zoho Developer console homepage.
  2. Select the extension that the connector has been associated to.
  3. Click Install Actions in the left pane.
  4. Select Connectors and click On Authorization.
  5. Select the connector that you want to include the authorization script in.
  6. Write the required code in the Deluge Script Editor.
  7. Click Execute if you want to test your code, or simply click Save to Connector.

Note:
  1. You can only write one post authorization script per connector.
  2. The post authorization script gets triggered automatically when the connector is authorized.
  3. This script will be triggered every time the connector is authorized.

Example
Consider a scenario where a user wants to register a webhook that will notify the CRM system when appointments are scheduled (created) in an external system. When this event of receiving a notification is not associated with any user action or input in the CRM system, it can be triggered by including a post authorization script for the connector. Thus, the webhook will be created when the extension that has the connector is used in the CRM system.  Similarly, you can perform any action using the post authorization script for connector.
  1. getmap = { "nameSpace" : "<portal_name.extension_namespace>"};
  2. apiresponse = zoho.crm.invokeConnector("crm.zapikey", getmap);
  3. zapikey = apiresponse.get("response");
  4. crm_signal_webhook_url = "https://platform.zoho.com/crm/v2/settings/custom_function/acuityschedulingext.createevent/execute?zapikey=%22 + zapikey;
  5. scheduledMap = { "triggerEvent" : "appointment.scheduled", ("targetUrl") : crm_signal_webhook_url };
  6. response = zoho.crm.invokeConnector("acuityschedulingext.acuityscheduler.regsiterwebhook", scheduledMap);
  7. info response;
  8. webhookid = response.get("id");
  9. setResp = zoho.crm.invokeConnector("crm.set", { "apiname" : "acuityschedulingext.webhookid", "value" : webhookid });
For registering a Webhook, a deluge function needs to be defined that can be exposed as a REST API. Once this function (createevent) is defined and saved, the REST API URL will be generated. This URL  ( https://platform.zoho.com/crm/v2/settings/custom_functions/acuityscheduling .createevent) is the Webhook URL that has to be provided to the third-party application. The code for the function is given below:
  1. resp = input.requestMap;
  2. appointmentId = resp.get("id");
  3. getsingleappointmentMap = { "id" : appointmentId };
  4. response = zoho.crm.invokeConnector(("acuityschedulingext.acuityscheduler.getsingleappointment"), getsingleappointmentMap);
  5. responseMap = (response.get("response")).toMap();
  6. fName = responseMap.get("firstName");
  7. lName = responseMap.get("lastName");
  8. mobile = responseMap.get("phone");
  9. email = responseMap.get("email");
  10. eventName = responseMap.get("type");
  11. createContactMap = { "First_Name" : fName, "Last_Name" : lName, "Mobile" : mobile, "Email" : email };
  12. m = map();
  13. l = List();
  14. l.add(createContactMap);
  15. m.put("module", "Contacts");
  16. m.put("data", l);
  17. contactResp = zoho.crm.invokeConnector("crm.create", m);
  18. info contactResp;
  19. newContactResp = (contactResp.get("response")).toMap();
  20. newDataMap = (newContactResp.get("data")).toMap();
  21. contactId = newDataMap.get("id");
  22. createEventMap = { "Event_Title" : eventName, "Who_Id" : contactId, "All_day" : false, "Start_DateTime" : ("2017-09-08T15:58:00+05:30"), "End_DateTime" : ("2017-09-08T15:58:00+06:30") };
  23. mapp = map();
  24. lapp = List();
  25. lapp.add(createEventMap);
  26. mapp.put("module", "Events");
  27. mapp.put("data", lapp);
  28. EventResp = zoho.crm.invokeConnector("crm.create", mapp);
  29. info EventResp;

Note
For more details about registering webhooks, refer to the guide on  Custom SalesSignal 

In the example mentioned above, after the webhook is successfully created, new record will be added in  Contacts and  Events module whenever a new appointment is created in the third-party application. The ID of the newly created webhook is set as an organization variable so that the value of the ID is available globally to be used at a later stage. To set the organization variable, follow the below steps:
  1. Click on Extension Settings in the left pane.
  2. Click Create.
  3. Enter the values as shown below:

      4. Click  Save.
After the webhook is successfully created, the following response will be obtained:


Create an on revoke script for connectors

After revoking the authorization of a connector, it might become necessary to nullify the workflow/action(s) associated with the connector. For example, you might want to disallow users from sending mail/SMS. These objectives cannot be achieved with the help of a custom function or workflow rules. To help you achieve this, Zoho Developer allows you to add a script (snippet of code or command) which will get executed during revocation of authorization of the connector.

To include a script post revocation of authorization of a connector:
  1. Click Extensions for Zoho CRM in the Zoho Developer console homepage.
  2. Select the extension that the connector has been associated to.
  3. Click Install Actions in the left pane.
  4. Select Connectors and click On Revoking.
  5. Select the connector you want to add the script to be executed in after revocation of the connector authorization.
  6. Write the required code in the Deluge Script Editor.
  7. Click Execute if you want to test your code, or simply click Save to Connector.

Note
  1. You can only write one post connector revocation script per connector.
  2. The post connector revocation script gets triggered automatically when the authorization of the connector is revoked.
  3. This script will be triggered every time the connector authorization is revoked.
 
Example
On revocation of the connector authorization, a registered webhook is deleted.
  1. webhookid = zoho.crm.getOrgVariable("acuityschedulingext.webhookid");
  2. m = { "id" : webhookid };
  3. resp = zoho.crm.invokeConnector("acuityschedulingext.acuityscheduler.deletewebhook", m);
  4. m = { "apiname" : "acuityscheduling.webhookid", "value" : 0 };
  5. setOrgVar = zoho.crm.invokeConnector("crm.set", m);

Execute a script on purchase

Using  Install Actions - On Purchase, you can execute activities when the end user buys an extension. You can use the script to enable certain features in the extension, notify users of the upgrade, etc.

The below screenshot depicts an extension's direct purchase and a purchase after the trial period (which can be done by navigating to  Setup > Marketplace > All > Installed and clicking on  Buy Now).




To include an on-purchase script for an extension:
  1. Log in to your Zoho Developer console and click Extensions for Zoho CRM.
  2. Select the extension you'd like to modify and click Edit.
  3. Click Install Actions in the left pane.
  4. Select Extension and click On Purchase.
  5. In the Deluge Script Editor, write the required code.
  6. Click Save and Execute if you want to test your code, otherwise click Save.



Note
This feature will be available only for paid extensions.

UpgradeMap Variable 

The upgradeMap variable will be available for the on-purchase script and can be used to obtain the following parameter values from Zoho CRM:
1. Organization ID - The unique Organization ID of the Zoho CRM account in which the extension is installed. The syntax to obtain the org ID is 
  1. <variable_name>= input.installParamMap.get("organizationId");
2. Installer ID - The unique ID of the user who installs the extension. The syntax to obtain the installer ID is
  1. <variable_name>= input.installParamMap.get("installerId");
 
Example
Imagine you have a creator application to keep track of the number of upgrades and downgrades of your extension. You can post data to this application whenever an upgrade happens.
  1. count = 0;
  2. resp = getUrl("https://creator.zoho.com/api/json/sales-commissions/view/All_Commissions?authtoken=21XXXXe&scope=creatorapi&raw=true%22);
  3. l = list();
  4. l = resp.get("Commissions");
  5. for each ele in l
  6. {
  7. uMap = ele.toMap();
  8. Upgrade_count = uMap.get("Upgrade_Count");
  9. Extension_Name = uMap.get("Extension_Name");
  10. ID = uMap.get("ID");
  11. if(Extension_Name == "acuityschext")
  12. {
  13. count = Upgrade_count + 1;
  14. myMap = Map();
  15. myMap.put("authtoken","21XXXXe");
  16. myMap.put("scope","creatorapi");
  17. myMap.put("Upgrade_Count",count);
  18. myMap.put("criteria","Extension_Name=acuityschext");
  19. resp = postUrl("https://creator.zoho.com/api/zoho_ownername/json/sales-commissions/form/Commissions/record/update%22,myMap);
  20. info resp;
  21. }
  22. }
 

Execute a script on plan downgrade

Using  Install Actions - On Plan Downgrade, you can create and execute a script to carry out actions when an end user's extension pricing plan is downgraded.

Paid extension end users can be downgraded to the free version. This can happen in one of two ways:

  1. The extension is automatically downgraded to the free version due to non-payment of charges by the end user.
  2. The end user chooses to leave the paid plan of the extension. The end user does this by selecting Cancel subscription in the Extension Details page (Setup > Marketplace > All > Installed and select the desired extension) in their CRM application as referred to in the screenshot below.



Note
This feature will be available only for paid extensions.

DowngradeMap Variable 

The  downgradeMap variable will be available for plan downgrade scripts and can be used to obtain the following parameter values from Zoho CRM:
1. Organization ID - The unique Organization ID of the Zoho CRM account in which the extension is installed. The syntax to obtain the org ID is 
  1. <variable_name>= input.installParamMap.get("organizationId");
2. Installer ID - The unique ID of the user who installs the extension. The syntax to obtain the installer ID is
  1. <variable_name>= input.installParamMap.get("installerId");
 

Example

A survey link can be sent to end users who downgrade their extension. The survey can be used to capture details of why the user chose to opt out of the paid version of the extension.
  1. sendmail
  2. [
  3. from :zoho.adminuserid
  4. to :zoho.loginuserid
  5. subject :"Extension Survey"
  6. message :"Hi, we would like to know the reason why you downgraded the extension to a free version. Please respond to the survey and help us improve.
  7. https://survey.zohopublic.com/zs/g1B3gM"
  8. ]

    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

                                                                                                              • Custom Actions

                                                                                                                This guide will help you with the following: Create Custom Actions  Associate with Workflow Rules  Manage Custom Actions  Zoho Developer provides various options to automate repetitive tasks and implement customizations that meet your business needs. ...
                                                                                                              • Functions

                                                                                                                This guide helps you with the following: Create Functions  Normal Functions REST API Functions Invoke Functions  Edit Functions  Delete Functions Rest API Functions Authentication Version 2.0 Version 1.0 Example Comparison of Version 2.0 and 1.0 ...
                                                                                                              • Custom Schedules

                                                                                                                This guide will help you with the following: Create Schedules  Write Custom Function  Edit Schedules  Delete schedules Schedules are automated user-defined actions, which can be performed through custom functions either at a particular time or on a ...
                                                                                                              • Quickstart Guide For Extensions

                                                                                                                Extensions—prebundled software components that can add a set of custom features to your Zoho CRM—enable developers to deliver a range of functionality not available by default on our system. This allows our partners to streamline the customization ...
                                                                                                              • Monitoring Audit Log

                                                                                                                The Audit Log is a chronological sequence of entries, each resulting from the actions performed by Users in Vertical Solutions. Audit logs are helpful to determine what has happened before and after an event, and also to identify records associated ...
                                                                                                                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