Using Business Rules
27 min
role administrators minimum version 2024 2 business rules implement domain specific business logic rules are defined in metadata as part of business object definitions business rules automate or aid business object interactions with a user, with other business objects, and with various services, both internal and external notable internal services include the workflow service, email service and escalation watch a domain model is defined as a set of interdependent business objects, where the dependencies are defined by relationships and business rules for example, you can link an incident to a customer via a relationship defined in metadata once you have established the link between the incident and the customer, you can derive other information from it, such as the department of the customer and contact information, including email address, of the customer then you can assign an incident to the appropriate owner, based on the services of each department after you have assigned an owner, the application sends an email to the customer with a status update and changes the status of the incident to active you can then link the email to the incident via a relationship the application starts the escalation watch and tracks metrics for the service level for the active incident these are all activities that are either automated by business rules, or are aided by them use the simplified expression editor in the business rules console at all the expression editor placeholders with the icon for more information refer to simplified expression editor docid\ aycvgwq xaxop0ofpgl9h about business rule inheritance does not support business rule inheritance if a business rule applies to a group business object, it does not also apply to the children business objects (unless you specifically apply it to a child business object) for example, the frs knowledge business object is a group business object and the faq business object is a child business rules for the frs knowledge business object do not apply to the faq business object therefore, you must apply business rules to all of the business objects that they apply to business rule types business rule type description triggered actions contain generic rules they are executed during business object transactions, typically when you save a business object the trigger is based on one of the events or a combination of events, such as business object events (insert, delete, or update), field events (initialize or update), or relationship events (link or unlink) you can also add an additional filter expression that if provided, is a predicate expression these rules are evaluated on the server side initialization rules business rules that the application executes when a business object is created the application executes the rules in the order listed therefore, the results of rules that are lower on the list can change depending on the returned values of the rules that are higher on the list you can reorder the initialization rules see modifying business rules docid\ a5ujt2tbpnhh zdyrll2w these rules are evaluated on the server side editing and calculation rules listed by condition the calculation rules are listed under the whenever fields are changed set condition business rules that automatically populate the value of a field when a dependent field changes these rules contain field references for example, the rule called isreclassifiedforresolution uses this expression $(if category != actualcategory then true else false) whenever the value of either the category field or the actualcategory field changes, the application executes the isreclassifiedforresolution rule editing rules, also called autofill rules, can also include calculation fields allowing you to define calculations on the field for editing rules, use the on change and set drop down lists to create a sequence add expressions in the field provided the results of these rules may also trigger additional business rules such as triggered actions these rules are evaluated on both the client side and the server side read only rules adds read only rules for entire business objects for example, you can render a business object as read only when the status field changes to resolved a business object must contain a read only field to use this option when a form is opened for a read only object, all controls (except those listed in the exception list) become read only when defining an exception list, it is important to understand which fields can be changed by business rules these fields must be also be added to the exceptions list updating a field that is not part of the exception list generates an error message child business objects are not affected when a business object is changed to a read only state however, you may not be able to link a new child business object to this business object these rules are evaluated on the client side, provided that the field is in the form that you are working on read only business rules for fields that are not in the form that you are working on are evaluated on the server side required rules determine when a field on a form must be filled out before you can save a record you can choose whether the field is always required or conditionally required based on an expression end users must provide the required values in the fields before saving the record if the field is available on the form, the rule is checked immediately on the client side if the field is not shown on the form, the system evaluates the rule on the server side after the form is submitted before save rules rules that are executed just before a business object is saved these business rules usually populate a field the application executes the rules in the order listed therefore, the results of rules that are lower on the list can change depending on the returned values of the rules that are higher on the list you can reorder the before save rules see modifying business rules docid\ a5ujt2tbpnhh zdyrll2w these rules are executed on the server side regular expression validation rules add custom validation rules based on regular expressions (regex) these rules run when you save an object see https //developer mozilla org/en us/docs/web/javascript/guide/regular expressions https //developer mozilla org/en us/docs/web/javascript/guide/regular expressions and http //stackoverflow\ com/questions/46155/validate email address in javascript http //stackoverflow\ com/questions/46155/validate email address in javascript for information about regular expressions the following regular expressions apply alphanumeric contains the validation type ^\[a za z0 9\s \\ ]+$ zip code contains the validation type ^((\d \d )|(\d )|(\[a z]\d\[a z]\s\d\[a z]\d))$ email contains the validation type ^\[a za z0 9]\((\[ \\ \\ ]?\[a za z0 9]+) )@(\[a za z0 9]+)((\\\[\\ \\ ]?\[a za z0 9]+) )\\ (\[a za z]{2,})$ phone us contains the validation type ^(\[0 9a fa f]\[0 9a fa f] ) (\[0 9a fa f]\[0 9a fa f])$ ip address contains the validation type ^(\d{1,2}|1\d\d|2\[0 4]\d|25\[0 5])\\ (\d{1,2}|1\d\d|2\[0 4]\d|25\[0 5])\\ (\d{1,2}|1\d\d|2\[0 4]\d|25\[0 5])\\ (\d{1,2}|1\d\d|2\[0 4] \d|25\[0 5])$ mac address contains the validation type ^\[01]?\[ ]?\\(?\[2 9]\d \\)?\[ ]?\d \[ ]? \d $ percent contains the validation type ^100$|^\s (\d{0,2})((\\ |\\,)(\d ))?\s \\%?\s $ custom requires the additional entry of a custom expression enter the message to show when this validation encounters an error these rules are executed on the client side this depends on the field references used in the rule validation rules prevent users from saving a record unless the result of the validation rule is true the validation rule calculates the result of an expression as a record is saved, and if the result of that calculation is false, the user cannot save the record you can define the error message shown to the user if the rule prevents saving the record an example is the validation expression found in the incident business object $( ((status != "closed") && (status != "resolved")) || istrueforallchildren("incident#", recid, "task#assignment rev3", "$(status == 'completed' || status == 'canceled')") ) this expression prevents a user saving an incident with a status of resolved or closed unless all child task#assignment records have a status of completed or canceled these rules are executed on the client side this depends on the field references used in the rule business rule engine states all business rules go through several states, as shown in the figure below business rule engine states business rule engine state description business rules initialization when you create a new instance of a business object typically the application displays a form with data in the fields initialization rules load when you are not creating a new instance of a business object, but are updating an existing business object calculation rules client update when clients (such as the user interface, workforce engine, email listener, and so on) enter data about the business object instance this is when the editing and calculation rules are executed to update the values when you save, the required and read only rules are executed on the client the client sends the data to the server editing rules calculation rules read only rules required rules server update when the server fills the business object with the data that the client submitted this is when the application executes editing and calculation rules this is the only state when triggered actions execute any of these business rules may cause the application to prompt the client for information if the client enters information, the flow goes back to the client update state editing rules calculation rules triggered actions before save the state immediately before saving the business object any of these business rules may cause the application to prompt the client for information if the client enters information, the flow goes back to the client update state before save rules validation the business object is now in a read only state on the server this is when the application validates all of the required rules and ensures that all validated fields meet the validated conditions any of these business rules may cause the application to prompt the client for information if the client enters information, the flow goes back to the client update state validation rules regular expression validation rules required rules after commit when certain quick actions are executed, such as send email action docid 5s8cpjuhfekkvvzc5 o2 note that this quick action was actually triggered in the server update state, but was not executed until this state read only rules editing business rule evaluation order a business rule can have a trigger field and one or more expression field dependencies there are two things that can cause a rule to execute trigger fields and expression field dependencies editing rule in the figure above, the owner field is the trigger field and \[otherobject]primaryemail is the expression field reference the expression field reference can have more than one expression in it the application activates a field reference dependency only after the editing rule has been triggered at least once by its trigger field trigger fields are not necessarily referenced in the expression field references business rule cycle dependencies some editing business rules may have cyclic dependencies business rule cyclic dependency in the figure above, in the first editing business rule, whenever there is a change to field 1, field 2 changes in the second editing business rule, whenever there is a change to field 2, field 1 changes this results in a cyclic dependency that cannot be properly evaluated in this case, there are no final values for field 1 and field 2 and the application cannot calculate the result however, there are cases where recursive editing rules do produce a definite and useful result and you do not need to avoid these rules when the application cannot evaluate recursive rules, the application stops re evaluating them at a certain point and returns a result that may not be the intended result we recommend that you avoid recursive business rules if a business rule returns the same value that its target already has, the application does not re evaluate its dependent rules using business rule tracing to turn on the rule trace, do the following from the configuration console, click monitor > application logs > logging configuration to open the logging configuration workspace double click the appserver ruletrace service to open it in the log level field, select a log level, such as debug, from the drop down list click save after you create an instance of a business object, such as creating an incident, you can review the logs associated with the rule trace by doing the following log in to open the logs workspace select rule trace from the saved search drop down list open a log entry, and view the data in the message field the message field lists all of the actions that the application has taken, including when it executed each rule at the beginning are the initialization rules, followed by editing and calculation rules the information may be very long and there may be more than one entry for each action it shows each and every rule that the application has executed viewing business rules you access the business rules from the configuration console from the configuration console, click build > business objects to open the business objects workspace open a business object click the business rules tab the application displays the business rules workspace the business rules are displayed in category groups to view all of the business rules in an expanded view, click expand rules to view the business rules in category groups, click collapse rules to view all of the business rules for a category in an expanded view, click the down arrow next to the category name to view just the business rule category name, click the up arrow next to the category name to reload the business rules, click reload to search for a term in a business rule, enter the term in the search area to search for a field name in a business rule, enter the field name in the search area and click search field names only to show business rules only for a certain form, select a form from the show rules for form drop down list creating a business rule business rules apply to records that are created after the business rule was created, and do not apply to existing records creating a triggered action docid\ a5ujt2tbpnhh zdyrll2wcreating an initialization rule docid\ a5ujt2tbpnhh zdyrll2wcreating an editing rule docid\ a5ujt2tbpnhh zdyrll2wcreating a calculation rule docid\ a5ujt2tbpnhh zdyrll2wcreating a read only rule docid\ a5ujt2tbpnhh zdyrll2wcreating a required rule docid\ a5ujt2tbpnhh zdyrll2wcreating a before save rule docid\ a5ujt2tbpnhh zdyrll2wcreating a regular expression validation rule docid\ a5ujt2tbpnhh zdyrll2wcreating a validation rule docid\ a5ujt2tbpnhh zdyrll2w creating a triggered action from the configuration console, click build > business object to open the business objects workspace open a business object select the business rules tab click triggered actions the triggered actions window appears list of triggered actions click add trigger select in the create triggered action window create a triggered action enter information into the fields trigger description trigger name name of the triggered action description optional description of the triggered action select an event that will trigger this action object event on insert runs when the business object is inserted object event on delete runs when the business object is deleted object event on update runs when the business object is modified and saved field event on initialize runs when a specific field is initialized select the field from the drop down list the following additional parameters appear when this option is selected, depending on the specified field is changed (runs when the field is modified) is set to condition (runs when the field is modified to a specific string) field event on update runs when a specific field is modified select the field from the drop down list the following additional parameters appear when this option is selected, depending on the specified field is changed (runs when the field is modified) is changed to condition (runs when the field is modified) is changed from condition (runs when the field is modified from a specific string) is changed from condition to other condition (runs when the field is modified from a specific string to a specific string) is set to condition (runs when the field is modified to a specific string) lastmoddatetime and lastmodby fields are not supported on update relationship event on link runs when a specified relationship is linked select the relationship from the drop down list relationship event on unlink runs when a specified relationship is unlinked select the relationship from the drop down list conditional expression in addition to the above criteria, the action will only trigger if the following expression is true specifies a boolean expression that allows the trigger to occur if this expression is true the action only triggers if both the selected event as specified above occurs and the expression specified in this field occur the action does not trigger if the expression specified in this field occurs but the selected event as specified above does not occur the action also does not trigger if the expression specified in this field does not occur but the selected event as specified above does occur both must occur for the action to trigger disable rule disables this triggered action select this option to create a read only business rule you cannot disable triggered actions that contain calculations click next >> select one of the following actions action description new action type configure new action configures a new quick action select a quick action from the drop down list see using quick actions docid\ qc7s yrfjjgp1ybk v 1s when creating a triggered action, the following actions are removed from the drop down list go to record, run for collection, go to action, and show a popup these actions cannot be used with triggers select action use copy of existing action uses a copy of an existing quick action select a quick action from the drop down list see using quick actions docid\ qc7s yrfjjgp1ybk v 1s when creating a triggered action, the following actions are removed from the dropdown list go to record , run for collection , go to action , and show a popup these actions cannot be used with triggers it lists the action names, which are associated with the following functions associated functions baseline composite action create rfc for variance create variance report delete object insert child object insert object inventory manager mobile push notification run program run rest web service run web service run for child search and link search and unlink send email start ipcm voice activity update object web service script it also lists functions names of the following deprecated functions, if you still have these in your environment license manager recognition rule send mobile notification unlink software inventory unlink software product click next >> to configure further or click save to save the triggered action if you select next >> for further configuration, the options that appear depend on the selected action type creating an initialization rule from the configuration console, click build > business object to open the business objects workspace open a business object select the business rules tab click initialization rules click add initialization rule add initialization rule enter information into the fields field description field name the field that the initialization rule applies to name an optional name for the initialization rule description an optional description for the initialization rule expression editor the expression that specifies the value that the initialization rule sets the field to disable rule specifies if the initialization rule is disabled click save creating an editing rule from the configuration console, click build > business object to open the business object workspace open a business object select the business rules tab click editing and calculation rules click add editing rule add editing rule enter information into the fields field description on change the field which, when changed, triggers the rule to execute set the field that gets changed when the field specified by the on change parameter changes assign only if target field is empty specifies to only change the value of the field specified by the set parameter if the value is empty the value does not change if there is a value already there invoke editing rules for the dependent fields of the target field (cascade change) enables the cascading effect name an optional name for the editing rule description an optional description for the editing rule expression editor the expression that specifies the value that the editing rule sets the field specified by the set parameter to disable rule specifies if the editing rule is disabled click save creating a calculation rule from the configuration console, click build > business object to open the business objects workspace open a business object select the business rules tab click editing and calculation rules click add calculation rule add calculation rule enter information into the fields field description field name the field to change by this calculation business rule condition specifies when the business rule is evaluated can be one of the following always the rule is not evaluated in the business rule engine state called before save or in the business rule engine state called after commit evaluated on the client side beforesave the rule is only evaluated in the business rule engine state called before save, before the business object is saved evaluated on the server side aftersave the rule is only evaluated in the business rule engine state called after commit, after the business object is saved evaluated on the server side also recalculate on load calculates the field value when reading the record from the database name an optional name for the calculation rule description an optional description for the calculation rule expression editor the expression that specifies the value that the calculation rule sets the field specified by the field name parameter to click save creating a read only rule from the configuration console, click build > business object to open the business objects workspace open a business object select the business rules tab click read only rules click add read only rule add read only rule enter information into the fields field description field name the field to change by this read only business rule this field is always read only specifies that the field specified by the field name parameter cannot be changed (that is, is read only) this field is conditionally read only based on an expression specifies that the field specified by the field name parameter cannot be changed (that is, is read only) depending on the value of the expression name an optional name for the read only rule description an optional description for the read only rule expression editor only used if you selected this field is conditionally read only based on an expression specifies a boolean expression that if evaluated to true, allows the field specified by the field name parameter to be read only disable rule specifies if the read only rule is disabled click save creating a required rule from the configuration console, click build > business object to open the business objects workspace open a business object select the business rules tab click required rules click add required rule add required rule enter information into the fields field description field name the field to change by this required business rule this field is always required specifies that the field specified by the field name parameter is always required this field is conditionally required based on an expression specifies that the field specified by the field name parameter is always required depending on the value of the expression name an optional name for the required rule description an optional description for the required rule expression editor only used if you selected this field is conditionally required based on an expression specifies a boolean expression that if evaluated to true, allows the field specified by the field name parameter to be required disable rule specifies if the required rule is disabled click save creating a before save rule from the configuration console, click build > business object to open the business objects workspace open a business object select the business rules tab click before save rules click add before save rule add before save rule enter information into the fields field description field name the field to change by this before save business rule name an optional name for the before save rule description an optional description for the before save rule expression the expression that specifies the value that the before save rule sets the field specified by the field name parameter to disable rule specifies if the before save rule is disabled click save creating a regular expression validation rule from the configuration console, click build > business object to open the business objects workspace open a business object select the business rules tab click regular expression validation rules click add regular expression validation rule add regular expression validation rule enter information into the fields field description field name the field to check the expression type for expression type the expression type can be one of the following alphanumeric contains the validation type ^\[a za z0 9\s \\ ]+$ zip code contains the validation type ^((\d \d )|(\d )|(\[a z]\d\[a z]\s\d\[a z]\d))$ email contains the validation type ^\[a za z0 9]\((\[ \\ \\ ]?\[a za z0 9]+) )@(\[a za z0 9]+)((\\\[\\ \\ ]?\[a za z0 9]+) )\\ (\[a za z]{2,})$ phone us contains the validation type ^(\[0 9a fa f]\[0 9a fa f] ) (\[0 9a fa f]\[0 9a fa f])$ ip address contains the validation type ^(\d{1,2}|1\d\d|2\[0 4]\d|25\[0 5])\\ (\d{1,2}|1\d\d|2\[0 4]\d|25\[0 5])\\ (\d{1,2}|1\d\d|2\[0 4]\d|25\[0 5])\\ (\d{1,2}|1\d\d|2\[0 4] \d|25\[0 5])$ mac address contains the validation type ^\[01]?\[ ]?\\(?\[2 9]\d \\)?\[ ]?\d \[ ]? \d $ percent contains the validation type ^100$|^\s (\d{0,2})((\\ |\\,)(\d ))?\s \\%?\s $ custom requires the additional entry of a custom expression error message the error message that the application displays if the field specified by the field name parameter is not the expression specified by the expression type parameter name an optional name for the regular expression validation rule description an optional description for the regular expression validation rule disable rule specifies if the regular expression validation rule is disabled click save creating a validation rule from the configuration console, click build > business object to open the business objects workspace open a business object select the business rules tab click validation rules click add validation rule add validation rule enter information into the fields field description validate on insert runs the validation business rule the first time that you create and save the business object validate on update runs the validation business rule whenever you modify the business object expression the expression that specifies the validation condition message the expression that specifies a validation message that is displayed if the expression specified by the expression parameter is not true name an optional name for the validation rule description an optional description for the validation rule disable rule disables the validation rule while it is being created click save enabling and disabling business rules you can enable or disable most business rules except for rules containing calculated fields by default, the application enables business rules when they are created from the configuration console, click build > business object to open the business object workspace open a business object select the business rules tab open a category of business rules to disable all of the business rules for a category, click disable all if you click disable all read only rules , the application displays a dialog box with information select an option disable and clear disables the rule and removes the read only restriction from existing business objects to enable all of the business rules for a category, click enable all to enable an individual business rule, click the off icon (the application shows the off icon because it is currently disabled ) to disable an individual business rule, click the on icon (the application shows the on icon because it is currently enabled ) if you disable modifying business rules business rules apply to records that are created after the business rule has been modified, and not retroactively to existing records use caution when modifying a business rule as it might affect dependent business objects from the configuration console, click build > business object to open the business object workspace open a business object select the business rules tab navigate to the business rule to modify click the edit icon the edit window appears make changes click save you can also move the order of the initialization and before save business rules by highlighting a business rule and clicking the up and down arrows on the right side of the list deleting a business rule use caution when deleting a business rule as it might affect dependent business objects from the configuration console, click build > business object to open the business object workspace open a business object select the business rules tab navigate to the business rule to delete click the delete icon the delete confirmation window appears click yes to delete the business rule
