Other Binds

Business rules can use any of the following 'Other' binds to access a variety of objects:

  • Attribute Validated Parameter
  • Attribute Value
  • Conditionally Invalid Values
  • Current Asset Content Object
  • Current Data Container Object
  • ID
  • Lookup Table Home
  • Mail Home
  • Name
  • Secret

The binds can be found within the 'Binds to' dropdown, as shown below.

Each bind is defined in the sections below.

Configuration

To use any bind:

  1. Create a business rule as defined in the Creating a Business Rule, Function, or Library topic.

  2. Edit the business rule as defined in the Editing a Business Rule or Function topic.

  3. In the Edit Operation dialog, add the bind to a business rule, as defined in the Adding a Bind topic in the Resource Materials online help documentation.

  4. In the Edit Operation dialog, optionally add Messages, as defined in the Localized Messages for JavaScript Business Rules topic.

  5. In the Edit Operation dialog, add JavaScript to call the bind.

Important: The example scripts should not be used as-is without thorough testing, including updating the script to match object and link types that exist on your system.

Attribute Validated Parameter

For more information, refer to the Parameterized Business Actions in Web UI topic in the Web UI Getting Started section of the Web User Interfaces documentation here.

Attribute Value

The value of the selected attribute is bound directly as a String variable. Primarily used for Web UI live validation of conditions and when defining Match Codes.

Note: This variable also works in the Web UI.

In this example, the Variable Name is 'primaryColorAttrValue', the Binds to field is Attribute Value, and the Parameters field displays the Primary Color attribute.

The following JavaScript returns a message when the value of the Primary Color attribute does not match the expected value of 'Gray':

Copy
   return primaryColorAttrValue == "Gray" ? true : "Primary Color is " + primaryColorAttrValue + " but it should be Gray.";

Conditionally Invalid Values

This bind is used with Conditional Attributes. For more information, refer to the Business Rules with Conditional Attributes documentation here.

For information about creating conditional attributes, refer to the Conditional Attribute Display section of the System Setup here.

Current Asset Content Object

This bind is used in Asset Publisher Image Conversion Conditions to bind asset content to restrict conversion to content meeting the condition, e.g., content with specific MIME types. For more information, refer to the Asset Publisher topic in the Digital Assets documentation here. Also, refer to the Asset Publisher Processing Plugin Parameters and Triggers topic within the Event Processors section of the System Setup documentation here.

An example:

Copy
if (content.getSimpleValue("asset.mime-type") == "image/tiff") {
    return true;
}

If you want to restrict conversion only on assets in specific classifications, then this should be a condition defined in the triggering condition on the queue (where it will be the asset itself that can be bound in the condition as opposed to asset-content).

Current Data Container Object

This bind is used in the 'Update Data Containers' Bulk Update operation, in the related JavaScript business conditions and actions. The selected data container is bound to the variable. For more information, refer to the Data Containers section of the System Setup documentation here.

Condition

This JavaScript business condition is used to find entities with Data Containers that have an attribute 'City' with the value 'New York'.

Copy
var cityname = dc.getValue("City").getSimpleValue();
var fixedname = "New York";
if (cityname == fixedname) {
return true;
}

Action

This JavaScript business action is then used to manipulate specified attributes on the Data Containers found.

Copy
dc.getValue("Street").setSimpleValue("(" + dc.getValue("Street").getSimpleValue() + ")");

ID

This bind resolves to the ID of current object (Java String).

The following code checks if the ID is not ‘Product hierarchy root’ then sets the ID to attribute NODEID.

Copy
//node = bind to current node
if (!id.equals(“Product hierarchy root”)) {
    node.getValue("NODEID").setSimpleValue(id);
}

Lookup Table Home

When bound to a variable, the variable will hold an object that allows you to work with transformation lookup tables from the script. The interface has a single public method that returns a String containing either the lookup value or the original value if no match could be made:

getLookupTableValue(String assetID, String value)
  • The first argument is the ID (string) of the lookup table, which is an asset.
  • The second argument is the string for which you want to get the lookup value.

For more information, refer to the Using JavaScript with Lookup Tables topic (here) and the Transformation Lookup Tables topic (here) in the Resource Materials documentation.

Mail Home

This bind allows the JavaScript to send emails. The bound class is the API Mail Home object.

Binds to the MailHome domain interface available for actions and conditions (although typically used with actions). After mail server settings are configured on STEP, this bind allows sending of emails that support full HTML.

In this example, 'Mail Home' is bound to the variable 'mailHome'.

Copy
mailHome.mail()
.from("Address of Sender")
.addTo("Address of Recipient", "Common Name")
.htmlMessage("Full HTML message:)
.subject("Subject of Email")
.send();

Note: Mail Home is the replacement for a previous bind called Mailer. It is important to note that once a rule using the old mail binding is edited and the bind is changed, users cannot get the old Mailer bind back. Removing the old bind means the Mail Home bind can only be used going forward.

Name

This bind resolves to the name of current object (Java String or null if no name).

In this example, 'Name' is bound to the variable 'name'. The code checks if there is a name.

Copy
//node = bind to current node
if (name) {
node.getValue("NODENAME").setSimpleValue(name);
}

Secret

The Secret bind option allows secrets, like passwords, to be stored in a secure manner. These can be referenced from the script. After having imported a business rule with a Secret bind, the secret must be reentered manually.

Note: Secrets cannot be moved between STEP systems using STEPXML export and import.