For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.
Zoho Creator: isBlank and isNull: Before or After?

Zoho Creator: isBlank and isNull: Before or After?

What?
A really quick article to test when to use isNull and isBlank.

Why?
So I've noticed that looking at people's Zoho Deluge code, there will often be a check on a null before or after the variable:
copyraw
if(v_Test.isBlank())
{
    ...
}
  1.  if(v_Test.isBlank()) 
  2.  { 
  3.      ... 
  4.  } 
VS
copyraw
if(isBlank(v_Test))
{
    ...
}
  1.  if(isBlank(v_Test)) 
  2.  { 
  3.      ... 
  4.  } 
isBlank() can be used to check if the string only contains blanks or if a value is null...

How?
Consider the following test function:
copyraw
void fn_Test()
{
	info "---------------------- Value of TEST is a BLANK String";
	v_Test = "";
	if(isBlank(v_Test))
	{
		info "isBlank Preceding is TRUE";
	}
	else 
    {
		info "isBlank Preceding is FALSE";
    }
	if(v_Test.isBlank())
	{
		info "isBlank Succeeding is TRUE";
	}
	else 
    {
		info "isBlank Succeeding is FALSE";
    }
	if(isNull(v_Test))
	{
		info "isNull Preceding is TRUE";
	}
	else 
    {
		info "isNull Preceding is FALSE";
    }
	if(v_Test.isNull())
	{
		info "isNull Succeeding is TRUE";
	}
	else 
    {
		info "isNull Succeeding is FALSE";
    }
	if(v_Test == null)
	{
		info "Equals Null is TRUE";
	}
	else 
    {
		info "Equals Null is FALSE";
	}
	info "---------------------- Value of TEST is NULL";
	v_Test = null;
	if(isBlank(v_Test))
	{
		info "isBlank Preceding is TRUE";
	}
	else 
    {
		info "isBlank Preceding is FALSE";
    }
	try
	{
		if(v_Test.isBlank())
		{
			info "Blank Succeeding is TRUE";
		}
	}
	catch (e)
	{
		info "isBlank Succeeding is FALSE:  " + e;
	}	
	if(isNull(v_Test))
	{
		info "isNull Preceding is TRUE";
	}
	else 
    {
		info "isNull Preceding is FALSE";
    }
	if(v_Test.isNull())
	{
		info "isNull Succeeding is TRUE";
	}
	else 
    {
		info "isNull Succeeding is FALSE";
    }
	if(v_Test == "")
	{
		info "Equals Blank is TRUE";
	}
	else 
    {
		info "Equals Blank is FALSE";
	}
}
//
// yields
/*
---------------------- Value of TEST is a BLANK String
isBlank Preceding is TRUE
isBlank Succeeding is TRUE
isNull Preceding is TRUE
isNull Succeeding is TRUE
Equals Null is FALSE
---------------------- Value of TEST is NULL
isBlank Preceding is TRUE
isBlank Succeeding is FALSE: Error at line : 57, Value is empty and 'isBlank' function cannot be applied
isNull Preceding is TRUE
isNull Succeeding is TRUE
Equals Blank is FALSE
*/
  1.  void fn_Test() 
  2.  { 
  3.      info "---------------------- Value of TEST is a BLANK String"; 
  4.      v_Test = ""
  5.      if(isBlank(v_Test)) 
  6.      { 
  7.          info "isBlank Preceding is TRUE"
  8.      } 
  9.      else 
  10.      { 
  11.          info "isBlank Preceding is FALSE"
  12.      } 
  13.      if(v_Test.isBlank()) 
  14.      { 
  15.          info "isBlank Succeeding is TRUE"
  16.      } 
  17.      else 
  18.      { 
  19.          info "isBlank Succeeding is FALSE"
  20.      } 
  21.      if(isNull(v_Test)) 
  22.      { 
  23.          info "isNull Preceding is TRUE"
  24.      } 
  25.      else 
  26.      { 
  27.          info "isNull Preceding is FALSE"
  28.      } 
  29.      if(v_Test.isNull()) 
  30.      { 
  31.          info "isNull Succeeding is TRUE"
  32.      } 
  33.      else 
  34.      { 
  35.          info "isNull Succeeding is FALSE"
  36.      } 
  37.      if(v_Test == null) 
  38.      { 
  39.          info "Equals Null is TRUE"
  40.      } 
  41.      else 
  42.      { 
  43.          info "Equals Null is FALSE"
  44.      } 
  45.      info "---------------------- Value of TEST is NULL"; 
  46.      v_Test = null
  47.      if(isBlank(v_Test)) 
  48.      { 
  49.          info "isBlank Preceding is TRUE"
  50.      } 
  51.      else 
  52.      { 
  53.          info "isBlank Preceding is FALSE"
  54.      } 
  55.      try 
  56.      { 
  57.          if(v_Test.isBlank()) 
  58.          { 
  59.              info "Blank Succeeding is TRUE"
  60.          } 
  61.      } 
  62.      catch (e) 
  63.      { 
  64.          info "isBlank Succeeding is FALSE:  " + e; 
  65.      } 
  66.      if(isNull(v_Test)) 
  67.      { 
  68.          info "isNull Preceding is TRUE"
  69.      } 
  70.      else 
  71.      { 
  72.          info "isNull Preceding is FALSE"
  73.      } 
  74.      if(v_Test.isNull()) 
  75.      { 
  76.          info "isNull Succeeding is TRUE"
  77.      } 
  78.      else 
  79.      { 
  80.          info "isNull Succeeding is FALSE"
  81.      } 
  82.      if(v_Test == "") 
  83.      { 
  84.          info "Equals Blank is TRUE"
  85.      } 
  86.      else 
  87.      { 
  88.          info "Equals Blank is FALSE"
  89.      } 
  90.  } 
  91.  // 
  92.  // yields 
  93.  /* 
  94.  ---------------------- Value of TEST is a BLANK String 
  95.  isBlank Preceding is TRUE 
  96.  isBlank Succeeding is TRUE 
  97.  isNull Preceding is TRUE 
  98.  isNull Succeeding is TRUE 
  99.  Equals Null is FALSE 
  100.  ---------------------- Value of TEST is NULL 
  101.  isBlank Preceding is TRUE 
  102.  isBlank Succeeding is FALSE: Error at line : 57, Value is empty and 'isBlank' function cannot be applied 
  103.  isNull Preceding is TRUE 
  104.  isNull Succeeding is TRUE 
  105.  Equals Blank is FALSE 
  106.  */ 
I've tried this in both Zoho Creator and Zoho CRM with the same results. I don't code with the method appended at the end of the variable but in more complex method chaining, I can see myself accidentally doing this. It's more that I saw other code like this and when reverse engineering or debugging the code, it may be worthwhile having a definitive idea of what will happen.

The intended purpose of isBlank()
copyraw
void fn_Test()
{
	info "---------------------- Value of TEST is a String with 2 blank spaces";
	v_Test = "  ";
	if(isBlank(v_Test))
	{
		info "isBlank Preceding is TRUE";
	}
	else 
    {
		info "isBlank Preceding is FALSE";
    }
	if(v_Test.isBlank())
	{
		info "isBlank Succeeding is TRUE";
	}
	else 
    {
		info "isBlank Succeeding is FALSE";
    }
	if(isNull(v_Test))
	{
		info "isNull Preceding is TRUE";
	}
	else 
    {
		info "isNull Preceding is FALSE";
    }
	if(v_Test.isNull())
	{
		info "isNull Succeeding is TRUE";
	}
	else 
    {
		info "isNull Succeeding is FALSE";
    }
	if(v_Test == null)
	{
		info "Equals Null is TRUE";
	}
	else 
    {
		info "Equals Null is FALSE";
	}
}
//
// yields
/*
---------------------- Value of TEST is a String with 2 blank spaces
isBlank Preceding is TRUE
isBlank Succeeding is TRUE
isNull Preceding is FALSE
isNull Succeeding is FALSE
Equals Null is FALSE
*/
  1.  void fn_Test() 
  2.  { 
  3.      info "---------------------- Value of TEST is a String with 2 blank spaces"; 
  4.      v_Test = "  "
  5.      if(isBlank(v_Test)) 
  6.      { 
  7.          info "isBlank Preceding is TRUE"
  8.      } 
  9.      else 
  10.      { 
  11.          info "isBlank Preceding is FALSE"
  12.      } 
  13.      if(v_Test.isBlank()) 
  14.      { 
  15.          info "isBlank Succeeding is TRUE"
  16.      } 
  17.      else 
  18.      { 
  19.          info "isBlank Succeeding is FALSE"
  20.      } 
  21.      if(isNull(v_Test)) 
  22.      { 
  23.          info "isNull Preceding is TRUE"
  24.      } 
  25.      else 
  26.      { 
  27.          info "isNull Preceding is FALSE"
  28.      } 
  29.      if(v_Test.isNull()) 
  30.      { 
  31.          info "isNull Succeeding is TRUE"
  32.      } 
  33.      else 
  34.      { 
  35.          info "isNull Succeeding is FALSE"
  36.      } 
  37.      if(v_Test == null) 
  38.      { 
  39.          info "Equals Null is TRUE"
  40.      } 
  41.      else 
  42.      { 
  43.          info "Equals Null is FALSE"
  44.      } 
  45.  } 
  46.  // 
  47.  // yields 
  48.  /* 
  49.  ---------------------- Value of TEST is a String with 2 blank spaces 
  50.  isBlank Preceding is TRUE 
  51.  isBlank Succeeding is TRUE 
  52.  isNull Preceding is FALSE 
  53.  isNull Succeeding is FALSE 
  54.  Equals Null is FALSE 
  55.  */ 

Conclusion
The recommended best practice for checking if the variable is null, contains blanks, or is simply an empty string would be:
copyraw
if(isBlank(v_Test))
{
	info "isBlank Preceding is TRUE";
}
  1.  if(isBlank(v_Test)) 
  2.  { 
  3.      info "isBlank Preceding is TRUE"
  4.  } 
If you're not expecting the user to enter any spaces at all and just want to check if the variable exists or is an empty string, then continue with:
copyraw
if(isNull(v_Test))
{
	info "isNull Preceding is TRUE";
}
  1.  if(isNull(v_Test)) 
  2.  { 
  3.      info "isNull Preceding is TRUE"
  4.  } 

Additional Note(s):
  • I've noticed that if the accepted content on an invokeURL in ZohoCreator is not JSON, then isNull() preceeding will not work. Instead you will need to do something like the following:
    copyraw
    m_Header = Map();
    m_Header.put("Authorization","Bearer <my_token>");
    m_Header.put("Accept","application/vnd.github+json");
    m_Header.put("X-GitHub-Api-Version","10-02-2025");
    //
    // query this user's events
    v_Endpoint_Events = "https://api.github.com/users/joel-the-awesomest/events";
    r_Events = invokeurl
    [
    	url :v_Endpoint_Events
    	type :GET
    	headers:m_Header
    ];	
    for each m_Event in r_Events
    {
    	if(m_Event.get("id") != null)
    	{
    		... do stuff
    	}
    }
    1.  m_Header = Map()
    2.  m_Header.put("Authorization","Bearer <my_token>")
    3.  m_Header.put("Accept","application/vnd.github+json")
    4.  m_Header.put("X-GitHub-Api-Version","10-02-2025")
    5.  // 
    6.  // query this user's events 
    7.  v_Endpoint_Events = "https://api.github.com/users/joel-the-awesomest/events"
    8.  r_Events = invokeUrl 
    9.  [ 
    10.      url :v_Endpoint_Events 
    11.      type :GET 
    12.      headers:m_Header 
    13.  ]
    14.  for each m_Event in r_Events 
    15.  { 
    16.      if(m_Event.get("id") != null) 
    17.      { 
    18.          ... do stuff 
    19.      } 
    20.  } 

Source(s):
Category: Zoho :: Article: 897

Add comment

Your rating:

Submit

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

Please publish modules in offcanvas position.