Business Condition: Function

Conditions can be formulated using STEP Functions, the functional language also used for Calculated Attributes and elsewhere in STEP. You can add function templates, and you can also insert an attribute ID by navigating to the relevant attribute.

The basic functionality is that a condition is true if the function evaluates to 1, and false if it evaluates to 0. Explicitly returning 1 or 0 is not required since a range of functions do this automatically.

For example, the following STEP Functions are available for use in business rules:

  • Binary logical functions <, >, <=, >=, =, != used for numerical comparisons
  • exact(string1, string2)
  • and(condition1, condition2, …)
  • or(condition1, condition2, …)
  • not(condition)
  • listcontains(list, text)

Conditions based on STEP Functions do not allow for dynamic user facing messages. For this type of condition, it is only possible to display an error message that is written in the error message text field, which cannot include any variables.

For more information, refer to the STEP Functions topic of the Resource Materials online help here.

Prerequisites

Before using this business condition:

  1. Create a business rule as defined in the Creating a Business Rule, Function, or Library topic here.
  2. Edit the business rule to configure the operation as defined in Editing a Business Rule or Function topic here.

Configuration

  1. On the Edit Operation dialog, select Function from the dropdown.
  2. For the Function parameter, add the function in the same way as you would in the Function Editor. For more information, refer to the Function Editor (here) topic or Using Function Editor (here) in the Resource Materials online help.
  3. For the Message when false parameter, specify the message to display when appropriate.
  • If a function returns 1, the condition is true.
  • If a function returns 0 or anything else but 1, the condition is false.
  1. Click Save to add this operation to the business condition.

Function Example

In this case, the user would like to compare both the values of two attributes: 'Availability' and 'Stock.' These attributes will be located in a 'Business Condition' attribute group for the sake of clarity.

Create the business condition using the steps earlier in this topic. To compare two attribute value strings, use the exact and value functions. Click the 'Insert Template' tab and select the 'Simple String Comparison.' This adds the exact() template to the function. Next, use the Insert Attribute ID option to add the two attributes using value(Availability) and value(Stock). Add a message for when the condition is false to provide context for other users. When completed, the function will appear like this:

Now that the business condition is set up, navigate to an object with these attributes and set both values to the same.

Return to the 'Global Business Rules' in the System Setup tab. Right-click on the business condition, and select 'Test Business Rule.' On the 'Test & Time Business Rule' dialog, select the test object where the Availability and Stock values are the same. Select 'Test.' The results will show that these attributes are the same.

Now, return back to the object and change one of the values. In this example, Stock is set to 'No.'

Return back to the business condition and test it again. The results will show that the two attributes are not the same.