Algorithm Value Generator

The Algorithm Value Generator allows users to generate a value based on business logic (e.g., concatenating two or more attribute values to create a new value, adding a category name to a product line to create a new value, etc.). Additionally, the Algorithm Value Generator can generate values produced by List Value Generators and/or Sequence Value Generators.

Important: While a powerful tool, the use of value generators can result in significant performance impacts in some scenarios. This is dependent on a number of factors and can be difficult to predict. Therefore, use of value generators should be thoroughly tested within your solution and as part of your overall business processes before relying on them as part of critical onboarding and/or import activities.

Prerequisites

Before an Algorithm Value Generator can be configured, a Value Generator Configuration Type must be created. For instructions on how to create a Value Generator Configuration Type, refer to the Value Generators topic here.

Business functions and business actions must also be configured to generate and release values using the Algorithm Value Generator.

While this topic includes specific requirements necessary for business functions and business actions to be used in tandem with Algorithm Value Generators, users need a working knowledge of business functions (e.g., creating and inputting binds, return types, input parameters, etc.), and a working knowledge of configuring and implementing business actions. Additionally, users should have an understanding of JavaScript and how it works in conjunction with business functions. For more information, refer to the Business Rules documentation here.

The diagram below visually displays how the Algorithm Value Generator works in relation with business actions and business functions to generate / release values.

Configuring Business Functions to Generate a Value

There are several ways in which a business function can be configured to be used in tandem with an Algorithm Value Generator, depending on business needs. This topic includes examples of business functions that have been configured to generate values using the Algorithm Value Generator. One example shows a business function that does not use integrated value generators to generate a value. Another example show a business function that uses integrated value generators (specifically, a List Value Generator and a Sequence Value Generator). 

Note: Although these examples demonstrate how business functions can be configured to work with an Algorithm Value Generator to generate a value, only the business function that uses integrated value generators is used in conjunction with the Algorithm Value Generator and business action examples addressed later in this topic.

Example business function for an Algorithm Value Generator that does not include integrated value generators

In this example, the business function has been configured in a way that does not use integrated value generators. This business function produces a value (in this case: a date) and checks for uniqueness of that value. If the date is not unique, it returns an empty string.

  1. Input Parameters:   Create a parameter name (in this example, 'vg'). Select Value Generator > 'ValueGenerator' as the type.
  1. Return Type: Select 'String' as the return type.
  2. JavaScript: A new date is returned as a value for the attribute if the value is unique. Otherwise, an empty string is returned as the value.

Note: Clicking the Test JavaScript button on the JavaScript Function for Value Generator can return a 'rollback performed' error. Instead, configure a business action (as defined in the sections below) to use the value generator and verify the result.

Example business function for an Algorithm Value Generator using integrated value generators

In this example, the business function has been configured to incorporate a List Value Generator and Sequence Value Generator to generate a value.

  1. Input Parameters: Create a parameter name (in this example, 'values'). Select Value Generator > 'IntegratedValueGeneratorsInput' as the type.
  2. Return Type: Select 'String' as the return type.
  3. JavaScript: If the value of a Sequence Value Generator (in this example, 'SeqVG') and the value of a List Value Generator (in this example, 'LVG') are not equal to null, return a value that combines the values from 'SeqVG' and 'LVG.' These values are separated by '/.' If either of these value generators are equal to null (that is, there are no available values), then an empty string is returned as the value.

Note: Clicking the Test JavaScript button on the JavaScript Function for Value Generator can return a 'rollback performed' error. Instead, configure a business action (as defined in the sections below) to use the value generator and verify the result.

For information regarding List Value Generators, refer to the List Value Generator topic here. For information regarding Sequence Value Generators, refer to the Sequence Value Generator topic here.

Configuring a Business Function to Release a Value

Although similar to business functions that are configured to generate values, there are a number of specific differences when editing a business function whose purpose is to be used in tandem with an Algorithm Value Generator to release a value. These setting are described in the example below.

Important: Values that have been released can be used at a later time. However, released values for the Sequence Value Generator cannot be used at a later time as doing so would disrupt the sequence of numbers.

  1. Binds:   Create a variable name (in this example, 'builder'). Select Value Generator > 'ValueReleaseOutputBuilder' as the binds to.
  2. Input Parameters: Create a parameter name (in this example, 'node'). Select 'Node' as the type.
  3. Input Parameters: Create a parameter name (in this example, 'value'). Select 'String' as the type.
  4. Return Type: Select Value Generator > 'ValueReleaseOutput' as the return type.
  5. JavaScript: If the value is equal to a combination of two values and comprised of a value made up of two values separated by a forward slash, the value is released.

Configuring an Algorithm Generator

Once a business function is configured, an Algorithm Value Generator can be configured. Users should configure the business function prior to configuring the Algorithm Value Generator, as part of configuring the Algorithm Value Generator is selecting the business function to be used to generate / release a value.

  1. With the desired Value Generator Configuration Type selected (in this case, AlgoVG), click the 'Edit' link, which is located under the Configuration flipper.

  1. Select 'Algorithm Value Generator' from the dropdown menu. The parameters for configuring the Algorithm Value Generator are now visible and ready for editing.

  1. Click the ellipsis button () next to the ' Business Function to Generate the Value' text field and select the business function to generate a value. In this example, the user has selected the second business function (the business function that includes two integrated value generators and is titled 'Generate Function') that was created earlier in this topic.
  1. Click the ellipsis button () next to the Business Function to Release the Value (Optional) text field, and select the business function to release a value. In this example, the user has selected the business function (titled 'Release Function') that was created earlier in this topic.
  1. In the 'Integrated Value Generators (Optional) text field, select the value generators you want to use within the Algorithm Value Generator by first clicking the green cross and then clicking the ellipsis button ().

In this example, the user has selected the List Value Generator ('LVG') and Sequence Value Generator ('SeqVG'), both of which are incorporated as part of the JavaScript within the first business function created earlier in this topic.

  1. Click 'Save' to save your settings and close the dialog.

Configuring a Business Action to Generate / Release Values

Business actions must be configured to assign / release values using the Algorithm Value Generator.

While this section includes details to configure business actions used in conjunction with the Algorithm Value Generator, it does not include the steps necessary to create the business actions. For more information regarding the initial setup of business actions (which are considered to be part of business rules), refer to the Business Rules documentation here.

  1. Within the business action Edit Operation dialog, select 'Value Generator' > 'Assign a value' or 'Release a value' from the dropdown menu, depending on which action to perform.
  2. Select an attribute and value generator. In this example the user has selected the attribute 'Product_Value1' and the value generator 'AlgoVG,' which was configured earlier in this topic.

'Assign a value' option

  • The value is assigned to the selected attribute.
  • The value is obtained from the selected value generator.

'Release a value' option

  • The value id removed from the selected attribute.

Important: Values that have been released can be used at a later time. However, released values for the Sequence Value Generator cannot be used at a later time as doing so would disrupt the sequence of numbers.

Once the business action configured to assign a value is run, the value for the attribute 'Product_Value1' is populated by a value as determined by the business function (in this case, a value taken from a Sequence Value Generator and List Value Generator, separated by a forward slash).

Once the business action configured to release a value is run, the value for the attribute 'Product_Value1' is removed from the attribute.

The value from the List Value Generator 'LVG' (125.1) has been placed back into the Available Values list and can be reused.