Working with Business Rules Externally
Business rules can be created, maintained, and tested outside of the system. This allowance enables users to govern the life cycle of business rules in a standard source code control system such as Git, and from there, be able to deploy appropriate versions of the business rules to the various systems that are part of a Development, Testing, Acceptance and Production (DTAP) environment.
For more information about the STEP GIT integration, refer to the Version Control System Integration topic in the Configuration Management documentation here.
Note: While it is possible to setup and import business rules into the system, it is easier to create dependencies, binds, valid object types, and any other required components of business rules inside of the MDM system where users can browse for the information needed rather than creating these connections.
Configuration
For this use case, a preexisting business rule will be exported from the system, augmented locally, and then, imported back into the system. Experienced developers may use this template to generate completely business rules outside of the system.
From the desired business rule in the workbench, right-click then select the 'Export in Editable Format' option.
Once exported, the business rule may be edited as desired. The following code snippet is an example of a business rule that will standardize addresses.
// Business rule metadata omitted /*===== business rule plugin definition ===== { "pluginId" : "JavaScriptBusinessActionWithBinds", "binds" : [ { "contract" : "CurrentObjectBindContract", "alias" : "node", "parameterClass" : "null", "value" : null, "description" : null }, { "contract" : "ReferenceTypeBindContract", "alias" : "refType", "parameterClass" : "com.stibo.core.domain.impl.ReferenceTypeImpl", "value" : "PrimaryProductImage", "description" : null }, { "contract" : "AssetBindContract", "alias" : "asset", "parameterClass" : "com.stibo.core.domain.impl.FrontAssetImpl", "value" : "100300", "description" : null }, { "contract" : "LoggerBindContract", "alias" : "logger", "parameterClass" : "null", "value" : null, "description" : null } ], "messages" : [ ], "pluginType" : "Operation" } */ exports.operation0 = function (node,refType,asset,logger) { // "Current Object" bound to "node" // A reference type bound to "refType" // An asset bound to "asset" var existingRefs = node.getReferences(refType).toArray(); if (existingRefs.length == 0) { logger.info("Creating reference"); node.createReference(asset, refType); } else { logger.info("Asset " + asset.getID() + " already has a Primary Product Image"); } }
Since the system uses binds to connect data to JavaScript, those are best maintained after the edited JavaScript file is imported back into the system. Once completed, it is recommended that developers test the business rule to ensure it functions as expected. For more information, refer to the Testing a Business Rule topic in this documentation here.