Creating an extension to integrate ZOHO Inventory with ZOHO Creator app

Mo
02/20/2024 04:14 PM Comment(s)

Introduction

ZOHO offers add-on development platform for ZOHO apps, aka Sigma. ZOHO starts supporting ZOHO financial apps including ZOHO Inventory on this platform. I would like to introduce how to connect ZOHO Inventory to ZOHO Creator using the Sigma platform.

Use Case

By connecting ZOHO Inventory with ZOHO Creator, you can further develop custom functionalities that the standard Inventory app cannot implemet by itself.

In this demo, I want to demonstrate 2 scenarios:

  1. When a sales order is created and issued in ZOHO Inventory, the order record is synchronized to the sales module in the ZOHO Creator app.
  2. When a purchase order is received in ZOHO Inventory, the order record is synchronized to the purchase order module in  the ZOHO Creator app.

Prerequisites

Install Inventory Management App

I will use pre-built application in ZOHO Creator in order to integrate with ZOHO Inventory.

I picked the Inventory Management application.


After sign-in, click "Create Solution" button on the top right corner.

Select "Inventory Management" app and click "install" button.

    Then, click "Pick" button in "Create from Gallery" box.

    Type "inventory" in the search box located on the top right corner.

    Select "Inventory Management" app and click "install" button.

    Selected application will be installed shortly.

    Creating ZOHO Inventory Extension

    Now that we have installed Inventory Management app in ZOHO Creator, we are ready to develop an extension using ZOHO Sigma.


    Go to ZOHO developer site (https://developer.zoho.com) and sign in. 

    Then select "Sigma"  and click "Start Building" button as shown below screenshot.

    Click "New Extension" button to create an extension.

    Add the extension name, and type a description of the extension.

    Select ZOHO Inventory icon in service section.

    Check the agreement statement.

    Then, click "Create" button.

    ZOHO Inventory Developer Portal will be displayed.

    Creating connections

    In order to access ZOHO Creator app, you need first to create an connection for ZOHO Creator. 

    Follow below steps:

    1. Click "Build" tab.
    2. Select "Connections" from left-side menu.
    3. Click "New Connection" button.

    Type "Creator" in the search box on the top left.

    Then, click "Zoho Creator" as a default service. 

    Configure the connection details.

    1. Enter "Connection Name".
    2. Turn this "Off"
    3. Select following Scopes:
  1. ZohoCreator.form.CREATE
  2. ZohoCreator.report.CREATE
  3. ZohoCreator.report.DELETE
  4. ZohoCreator.report.READ
  5. ZohoCreator.report.UPDATE
  6. Click "Connect".

    Click "Connect"  for ZOHO Flow access.

    Click "Accept" to allow an access.

    The connection to ZOHO Creator is created.

    Creating Workflow Rules

    Now that the connection between ZOHO Inventory and ZOHO Creator is established, next step is to create an automation rule.

    I will create 2 rules to trigger custom actions.

    Rule 1: When a Sales Order is created and issued.

    Rule 2: When Purchase Order is created and received.


    1. Select "Workflow Rules" menu.
    2. Click "+ New Workflow Rule" button.

    Follow below steps to configure Workflow Rule 1. (Refer to below screenshot.)

    1. Enter "Workflow Rule Name".
    2. Select "Sales Order" Module.
    3. Select "Event Based".
    4. Select "Created or Edited"
    5. Select "Any field is updated".
    1. Configure the trigger to select  "Status",  "is" and "Open".
    2. Select "Just Once".
    3. Configure the actions. (For now, just select "in-app Notification" and create a in-app notification with a message. )*
    4. Click "Save"  to create a Workflow rule.

    *This will be replaced by a custom action we will create later. 

    Follow below steps to configure Workflow Rule 2. (Refer to below screenshot.)

    1. Enter "Workflow Rule Name".
    2. Select "Purchase order" Module.
    3. Select "Event Based".
    4. Select "Created or Edited"
    5. Select "Any field is updated".
    1. Configure the trigger by selecting  "Purchase Receive Status",  "is" , "Received", "OR",  "Purchase Receive Status",  "is" and "Partially Received".
    2. Select "Just Once".
    3. Configure the actions. (For now, just select "in-app Notification" and create a in-app notification with a message. )*
    4. Click "Save"  to create a Workflow rule.

    *This will be replaced by a custom action we will create later. 

    Creating Workflow Actions

    As workflow actions, I will develop the following custom functions:

    1. Creating a sales order in Inventory Management app in ZOHO Creator when a sales order is created in ZOHO Inventory.
    2. Creating a purchase order in Inventory Management app in ZOHO Creator when a purchase order is created and received.

    To create custom functions, follow below steps:
    1. Select "Workflow Actions" from left menu.
    2. Select "Custom Functions" from submenu.
    3. Click "+ New Function" button.

     Developing a custom function to synchronize a sales order

    Follow below steps to create a custom function.

    1. Type "Function Name".
    2. Select "Sales Order" module.
    3. Check "Global Fields" to allow use of global fields.

    Refer to the below sample code to write deluge scripts in the editor and click "Save" button.

     Developing a custom function to synchronize a purchase order

    Follow below steps to create a custom function.

    1. Type "Function Name".
    2. Select "Purchase Order" module.
    3. Check "Global Fields" to allow use of global fields.

    Refer to the below sample code to write deluge scripts in the editor and click "Save" button.

    Updating Workflow Rules

    Now that custom functions are created, we need to update actions in workflow rules.

    1. Select "Workflow Rules" menu.
    2. Click workflow name, "Sales Order Created".
    1. Scroll down to "4. Action" setting.
    2. Select  "Custom Function"  as "Type" 
    3. Select the custom function, "create_sales_order_in_inventory_management",  you just created for the sales order module.
    4. Click "Save" button to apply the change.

    Next, click Workflow name, "Purchase Order Created".

    1. Scroll down to "4. Action" setting.
    2. Select  "Custom Function"  as "Type" 
    3. Select the custom function, "create_purchase_order_in_inventory_management",  you just created for the sales order module.
    4. Click "Save" button to apply the change.

    Configuring Global Fields

    When connecting ZOHO Creator app from ZOHO Inventory extension, we need to configure the API endpoint in deluge scripts.

    We need to specify "Space" name and "App Name" as a part of the endpoint URL.

    However, those vales are depends on user's account for which the extension will be installed.

    To solve this, we can use global fields to hold those values and paas them to custom functions as parameters.

    Follow below steps to set up "Global Fields".


    1. Select "Configure" tab.
    2. Select "Global Fields" Menu.
    3. Click "+ New Field" button.
    1. Type field "Name".
    2. Type "Description".
    3. Select "Text Box (Single Line)" as Data Type.
    4. Type your account's space name.
    5. Select "Read Only".
    6. Click "Save".

    You can find the "space name" and "app name" in the creator app URL.

    Follow the same steps to configure the global field for "app name".

    To get global field values in deluge, refer to the below scripts.

    You need the "placeholder" name to retrieve values in the script.

    Testing the extension

    In order to test the extension, you can use the sandbox.

    1. Click "Test Your Extension" link on the top left corner.
    2. The sandbox ZOHO Inventory app opens in the separate window. 

    You need to add, at least, an organization, a warehouse, and a product.

    Those records must match between ZOHO Inventory and ZOHO Creator app.

    1. Create new sales order.
    2. Click "Save as Draft".

    Click "Mark as Confirmed".

    1. Open Inventory Management app in ZOHO Creator.
    2. Confirm new sales order is created in Sales Details module.

    Next, test for a purchase order.

    1. Create new purchase order.
    2. Click "Save as Draft".

    Click "Receive" button.

    Click "Save as Received".

    1. Open Inventory Management app in ZOHO Creator.
    2. Confirm new purchase order is created in Purchase Details module.

    Publishing the extension

    1. Select "Publish" tab.
    2. Click "Publish" button.

    Conclusion

    We demonstrated how to create a extension with ZOHO Inventory.

    We use Sigma Platform in order to publish the extension.

    You can create the same with ZOHO Inventory "Automation" setting.

    It is quite easy to extend standard ZOHO Inventory functionality with ZOHO Creator using extension.

    Mo