Business Rules 101: Comparable Functions & Picking the Right One | Rithum

Business Rules 101: Comparable Functions & Picking the Right One

April 3, 2017

This blog post is part of a series designed to demystify the process of understanding and writing your own business rules.

There are a handful of business rule functions that perform similarly but have slightly different designs and purposes. Today’s post focuses on those similar business rule functions and how to decide which one will output the information you need.

CONCATENATE, JOIN, or JOINNB

These three functions allow you to combine multiple fields of data including explicit/static values, and other business rule functions in any format and order you define.

CONCATENATE allows you to combine up to 8 values together exactly as those values appear in the rule. You can extend the length by nesting other CONCATENATE functions within the primary CONCATENATE rule.

When to Use: When you need to combine data points or the results of other functions.

Caution: blank fields may alter the look of the result, and spaces aren’t entered automatically between values – they must be explicitly defined.

JOIN ultimately does the same thing as CONCATENATE to bring values together, but allows you to combine up to 8 values and choose how those values should be delimited. Here you’ll define a delimiter as the first variable, then define the values in the same way as CONCATENATE.

When to Use: when you need to combine multiple data points or the results of other functions by the same delimiter, and when you need to generate new strings of field data on the fly so it can be used for other purposes.

Caution: blank fields may alter the result in ways you may not intend.

JOINNB also allows you to combine up to 8 values and choose how those values should be delimited, but it will also eliminate blank values from the result, so you won’t have multiple delimiters back to back. This function offers the most control, flexibility, and the cleanest result simply by using the function. Your chosen delimiter is applied with the first variable, then values are defined in the same way as in JOIN.

When to Use: When you need to combine multiple data points or the results of other functions by the same delimiter, and you don’t know if or when those fields or functions have data in them. This function is also often used to generate new strings of field data, so the resulting data can be used for other purposes like direct outbound mapping, or converting the resulting data into valid values.


Pro Tips

Extend the length of any of the above rules by nesting the same function in the place of any of the values. Just remember to close each function with the appropriate number of parenthesis!


ISBLANK and IFBLANK

Both of these functions will allow you to evaluate blank data, but they have slightly different purposes.

ISBLANK allows you to evaluate a field or function to determine if it is or generates no value. The output of the rule is ‘TRUE’ or ‘FALSE’. It’s most often used within the IF and SELECTCASE functions, which both require evaluation of a condition to a TRUE or FALSE value, but there are other practical uses including simple rules that generate TRUE/FALSE for excluding products from a feed.

When to Use: when you need to determine if a single field is blank or if a function generates a blank.

IFBLANK allows you to return the first non-blank result in a comma separated list. A maximum of 8 fields or other functions can be evaluated with a single IFBLANK. The output is entirely different from ISBLANK in that you won’t generate a TRUE or FALSE result — instead, you’re returning a field value, static value, or result of a rule.

When to Use: when you have multiple fields you can use for a particular purpose and know the order in which you wish to use them, but you don’t know which are populated from one product to the next.


Pro Tips


LEFT or LEFTWORD

The purpose of these functions is to grab part of a value starting from the left side of the data to a specific length. One offers additional flexibility for a cleaner result.

LEFT allows you to define the number of characters (from the left side of the value) to include from a field. Requires you define the field and the number of characters.

When to Use: when you need a hard cutoff at a certain number of characters (usually to ensure you’re at or below the maximum length of a field).

Caution: this will end the value at the character count regardless of location.

LEFTWORD allows you to define both a maximum length of the value and the delimiter where the cutoff should happen before the maximum length, which provides a better-looking output because it reduces the possibility a field may be cut off in the middle of a word.

When to Use: when you need a hard cutoff at a certain maximum length but want a clean, rather than abrupt, end point, and know that the delimiter data generally will exist for most products.

Caution: If the delimiter doesn’t exist in the field at all or if the first instance of the delimiter exists after the maximum defined length, the rule generates a blank.

Caution: If the last delimiter falls well short of the maximum length, this is still where the cutoff will happen, and the overall length may be very short.


Pro Tips