For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.
ZohoCRM / Client Script / Canvas: Hide Tab based on Pipeline

ZohoCRM / Client Script / Canvas: Hide Tab based on Pipeline

What?
A quick article with snippets of code to hide and show certain tabs on a deal record based on the pipeline.

Why?
A request from a customer asked if a tab specific to the pipeline selected can be shown while others hidden. Standard tabs such as Notes, Attachments, Emails, and Timeline should remain.

Code will be needed as a layout rule couldn't control the tabs on a canvas view page. An additional function is needed as the pipeline was not displayed on the canvas view of the deal record but it was on the edit page.

How?
First we're going to add some element IDs to the canvas view page on each of the tabs. Then we'll make an OAuth function that can be executed by the client script which returns the value of the Pipeline given a deal record ID. Finally, we'll have client script execute this function, then show/hide tabs based on the value.

Assuming I have a tab called "Sales Pipeline", and "Hire Pipeline":
  1. Go to the deal record and scroll to bottom where you can see an "Edit" button for this canvas.
  2. The edit mode of the canvas will popup in a new tab.
  3. Right-click on the tab you want to hide and click on "Add Element ID" (or "Change Element ID" if already set).
  4. Call them something easy to remember such as "Tab_SalesPipeline" and "Tab_HirePipeline".
  5. Save and close the edit mode of the Canvas.

Function to return pipeline
  1. Login as a ZohoCRM Administrator and go to Setup > Developer Hub > Functions > New Function
  2. Give it a function name, display name, description, and set category to "Standalone": I'm calling mine "fn_Deals_RetrievePipeline"
  3. Give it the following code:
    copyraw
    string standalone.fn_Deals_RetrievePipeline(String p_DealID)
    {
    	/* *******************************************************************************
    	Function:       string standalone.fn_Deals_RetrievePipeline(String p_DealID)
    	Label:          Fn - Deals - Retrieve Pipeline
    	Trigger:        Standalone / REST API
    	Purpose:	    Function used by a client script to retrieve the pipeline given a deal record id
    	Inputs:         Deal Record ID
    	Outputs:        the value of the pipeline
    
    	Date Created:   2025-05-06 (Joel Lipman)
    					- Initial release
    	Date Modified:	???
    					- ???
    	******************************************************************************* */
    	v_Pipeline = "";
    	r_RecordDetails = invokeurl
    	[
    		url :"https://www.zohoapis.com/crm/v8/Deals/" + p_DealID + "?fields=Pipeline"
    		type :GET
    		connection:"zcrm"
    	];
    	l_DealData = ifnull(r_RecordDetails.get("data"),List());
    	for each  m_DealData in l_DealData
    	{
    		if(!isNull(m_DealData.get("id")))
    		{
    			r_DealDetails = m_DealData;
    			if(!isNull(r_DealDetails.get("Pipeline")))
    			{
    				v_Pipeline = r_DealDetails.get("Pipeline");
    			}
    		}
    	}
    	return v_Pipeline;
    }
    1.  string standalone.fn_Deals_RetrievePipeline(String p_DealID) 
    2.  { 
    3.      /* ******************************************************************************* 
    4.      Function:       string standalone.fn_Deals_RetrievePipeline(String p_DealID) 
    5.      Label:          Fn - Deals - Retrieve Pipeline 
    6.      Trigger:        Standalone / REST API 
    7.      Purpose:        Function used by a client script to retrieve the pipeline given a deal record id 
    8.      Inputs:         Deal Record ID 
    9.      Outputs:        the value of the pipeline 
    10.   
    11.      Date Created:   2025-05-06 (Joel Lipman) 
    12.                      - Initial release 
    13.      Date Modified:    ??? 
    14.                      - ??? 
    15.      ******************************************************************************* */ 
    16.      v_Pipeline = ""
    17.      r_RecordDetails = invokeurl 
    18.      [ 
    19.          url :"https://www.zohoapis.com/crm/v8/Deals/" + p_DealID + "?fields=Pipeline" 
    20.          type :GET 
    21.          connection:"zcrm" 
    22.      ]
    23.      l_DealData = ifnull(r_RecordDetails.get("data"),List())
    24.      for each  m_DealData in l_DealData 
    25.      { 
    26.          if(!isNull(m_DealData.get("id"))) 
    27.          { 
    28.              r_DealDetails = m_DealData; 
    29.              if(!isNull(r_DealDetails.get("Pipeline"))) 
    30.              { 
    31.                  v_Pipeline = r_DealDetails.get("Pipeline")
    32.              } 
    33.          } 
    34.      } 
    35.      return v_Pipeline; 
    36.  } 
  4. Give the argument/parameter "p_DealID" which in this case will be a string. Use the # symbol to map it to "Deals.Deal Id"
  5. Save and close the function
  6. In the list of functions, hover over the function you just made and select "REST API"
  7. Enable both OAuth and REST API
  8. Click on "Save" to close the dialog box

Client script to show/hide tabs
  1. Login as a ZohoCRM administrator and go to Setup > Developer Hub > Client Script > New Script
  2. Give it a name, I'm calling mine "CsfnShowSectionBasedOnPipeline" with a description
  3. Set Page to "Detail Page (Canvas)"
  4. Set the Module to "Deals"
  5. Select your layout and canvas to apply this to
  6. Under Event, set the type to "Page Event" and set the Event to "onLoad"
  7. Give it the following code:
    copyraw
    /* *******************************************************************************
    Function:       function onLoad ()
    Label:          CsfnShowSectionBasedOnPipeline
    Trigger:        Client Script on Load of the Deal record page
    Purpose:	    Retrieves the pipeline of the deal record and hides/shows sections accordingly.
    Inputs:         -
    Outputs:        -
    
    Date Created:   2025-05-06 (Joel Lipman)
                    - Initial release
    Date Modified:	???
                    - ???
    ******************************************************************************* */
    
    // clear the console so I can see what this script is doing (among all the zoho warnings/errors)
    console.clear();
    
    // try and catch exception
    try {
    
        // get the record ID currently displayed
        var v_ThisRecordID = $Page.record_id;
    
        // get the record details of this deal
        // not this way: var r_DealDetails = ZDK.Apps.CRM.Deals.fetchById(v_ThisRecordID);
        // but using a custom OAuth function:  Setting this as REST API alone did not enable it.
        var r_DealDetails = ZDK.Apps.CRM.Functions.execute("fn_Deals_RetrievePipeline", {"p_DealID": v_ThisRecordID});
    
        // Parse the response to retrieve just the pipeline value (returned string)
        var v_DealPipeline = r_DealDetails._details.output;
    
        // set all tabs to hidden
        ZDK.UI.getElementByID("Tab_SalesPipeline").setVisibility(false);
        ZDK.UI.getElementByID("Tab_HirePipeline").setVisibility(false);
        
        // depending on pipeline, show the tab
        if (v_DealPipeline == "Sales Pipeline") {
            ZDK.UI.getElementByID("Tab_SalesPipeline").setVisibility(true);
            ZDK.UI.getElementByID("Tab_SalesPipeline").setActive();
        }
        else if (v_DealPipeline == "Hire Pipeline") {
            ZDK.UI.getElementByID("Tab_HirePipeline").setVisibility(true);
            ZDK.UI.getElementByID("Tab_HirePipeline").setActive();
        }
    
    } catch (e) {
    
        // display exceptions to console watchers
        console.log(e);
    }
    1.  /* ******************************************************************************* 
    2.  Function:       function onLoad () 
    3.  Label:          CsfnShowSectionBasedOnPipeline 
    4.  Trigger:        Client Script on Load of the Deal record page 
    5.  Purpose:        Retrieves the pipeline of the deal record and hides/shows sections accordingly. 
    6.  Inputs:         - 
    7.  Outputs:        - 
    8.   
    9.  Date Created:   2025-05-06 (Joel Lipman) 
    10.                  - Initial release 
    11.  Date Modified:    ??? 
    12.                  - ??? 
    13.  ******************************************************************************* */ 
    14.   
    15.  // clear the console so I can see what this script is doing (among all the zoho warnings/errors) 
    16.  console.clear()
    17.   
    18.  // try and catch exception 
    19.  try { 
    20.   
    21.      // get the record ID currently displayed 
    22.      var v_ThisRecordID = $Page.record_id; 
    23.   
    24.      // get the record details of this deal 
    25.      // not this way: var r_DealDetails = ZDK.Apps.CRM.Deals.fetchById(v_ThisRecordID)
    26.      // but using a custom OAuth function:  Setting this as REST API alone did not enable it. 
    27.      var r_DealDetails = ZDK.Apps.CRM.Functions.execute("fn_Deals_RetrievePipeline", {"p_DealID": v_ThisRecordID})
    28.   
    29.      // Parse the response to retrieve just the pipeline value (returned string) 
    30.      var v_DealPipeline = r_DealDetails._details.output; 
    31.   
    32.      // set all tabs to hidden 
    33.      ZDK.UI.getElementByID("Tab_SalesPipeline").setVisibility(false)
    34.      ZDK.UI.getElementByID("Tab_HirePipeline").setVisibility(false)
    35.   
    36.      // depending on pipeline, show the tab 
    37.      if (v_DealPipeline == "Sales Pipeline") { 
    38.          ZDK.UI.getElementByID("Tab_SalesPipeline").setVisibility(true)
    39.          ZDK.UI.getElementByID("Tab_SalesPipeline").setActive()
    40.      } 
    41.      else if (v_DealPipeline == "Hire Pipeline") { 
    42.          ZDK.UI.getElementByID("Tab_HirePipeline").setVisibility(true)
    43.          ZDK.UI.getElementByID("Tab_HirePipeline").setActive()
    44.      } 
    45.   
    46.  } catch (e) { 
    47.   
    48.      // display exceptions to console watchers 
    49.      console.log(e)
    50.  } 
  8. Click on "Save and Close"
Done.
Category: Zoho CRM :: Article: 428

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com