Select Page

No Values: Much Ado About Nothing

by | Last updated on Nov 5, 2024

In computer terms, what is nothing, and why should you care? Even for rule authors with a development background, a quick review of how InRule handles “nothing” values can be useful for those occasions when you need to know if you have a value. In this post, I’ll cover which techniques you need to employ if you’re dealing with “nothing” values.

For the purposes of this article, I’m defining “nothing” as a catch-all term to represent any of the following:

  • A null value
  • An empty field
  • A collection with no members

How Nothing is Represented in InRule

To help clarify how nothing is represented in InRule, let’s examine the following irVerify screen, which shows null fields of several types, and an instantiated entity field (LoanInfo).

irVerify Null Values

Fields with No Default Value

In irVerify, a field without a default value is shown as a null field to which one can load or assign a value. A special note is that a null Boolean field is shown as a box with a black filling (see IsRefinance in the picture above).

Fields with Default values

The use of “Default value” on a field will cause that field to have a value. If the default value is checked, but no value is present in the default value box, irVerify will populate those fields with the following default values for that data type:

  • Boolean: the value “false” (see IsJumbo in the picture)
  • Text: an empty string
  • Integer / Decimal: the value “0”
  • Date: the date “1/2/0001”

Entity Fields and their Children

Entity fields will be null by default in irVerify. However, checking the default value checkbox will instantiate (create an instance of) that field. See LoanInfo above for an example. If an entity field is instantiated, all of the fields beneath that entity field will be set to null (unless a specific field’s default value checkbox is checked).

Collections

Null is not a term that applies to Collections. Collections may have 0 members or more than 0 members, but collections are never null. Payments in the above screenshot is an empty collection.

Checking for Nothing (Null, Empty Fields, Empty Collections)

In irAuthor, you may wish to write logic to check if something contains nothing. Why? Perhaps you do not wish to proceed with logic if null values are encountered, or perhaps you wish to return a message if certain fields are left empty.

Fields can be checked for null. Collections cannot be checked for null, but authors can check to see if that collection has 0 (or more) members.

Assume all statements begin with an if… command.

Item Syntax Technique Business Language Technique
Field IsNull() …<field> is null
Field IsNullOrEmpty() …<field> is null or empty
Collection Count(Collection) = 0Count(Collection) > 0 …no members exist in <collection>…any members exist in <collection>

Setting Nothing Values

It is worth making a mental note that all fields begin as null in irVerify, and all collections begin with 0 members. Having said that, if you wish to use logic to set a field as null or a collection as having 0 members, the following techniques should be used.

Item How to Set it as Nothing
Fields Use the syntax set value command to set the field to null. This technique cannot be used in business language rules.In business language, instead of null, an empty string can be used (“”) to set an empty (but not null) value that will be caught by the IsNullOrEmpty() function.
Entity Field 1.      Create another (temporary) field of the same data type2.      Use a set value statement to set the value of the entity field to the temporary entity field
Collection Use the clear collection command

Examples of Setting Empty Values and Clearing Collections

Business Language Rule

And that’s it: that’s most of what you need to know about “nothing” values in InRule. If you have any suggestions for updates to this article, or if you’ve got additional questions, please feel free to email the ROAD Services team.

BLOG POSTS BY TOPIC:

FEATURED ARTICLES:

STAY UPDATED ON THE LATEST FROM INRULE

We'd love to send you monthly updates! Learn about our webinars and newly published content by subscribing to our emails. We'll never share your email address and you can easily unsubscribe at any time.