Adding the BadCreateAccount Rule
The
BadCreateAccount
rule has a higher priority, so it will fire before the
CreateAccount
rule.
- Procedure
- Right-click the
Rules
folder, and select
.
You will see the New Rule Wizard.
- In the
Rule name field, type
BadCreateAccount.
In the Description field, type
Checks for an existing account with the specified ID.
- Click Finish.
- In the
Form tab, set the Priority field to
3
.This is a higher priority than 5, the default. You’ll set theCreateAccount
rule to priority 5, so that theBadCreateAccount
rule always fires beforeCreateAccount
rule. - Expand the
Declaration section as needed so you can see empty rows below the headings Term and Alias.
Each of the sections can be expanded and contracted as needed.
- Drag the Account concept from the TIBCO BusinessEvents Studio Explorer tree into the first empty row in the
Declaration section.
You will see the project path of the Account concept in the Term column, and
account
in the Alias column. - Similarly, drag the
CreateAccount
event into the next available row.DeclarationThe Declaration provides the scope of the rule. It lists all the entity types to be used in the rule, and their aliases. By default the alias is set to the entity name in lower case letters. You can change it as desired. - In the
Conditions panel, type the following:
//Checks whether the extId of an Account instance in working memory //matches the incoming event's account ID account@extId == createaccount.AccountId;
Notice that when you type the At sign (@), a pick list of concept attributes appears. Attributes are built-in. You cannot add or remove attributes. The
id
attribute value is set internally. However you can set the external ID,extId
. - In the
Actions panel, just below the
Conditions panel, type these statements:
System.debugOut("#### Account already exists: " + createaccount.AccountId); Event.consumeEvent(createaccount);
These actions are done only if the conditions are met. If not, then the next rule in the agenda fires — and that is likely to be the
CreateAccount
rule, which you’ll define next.You are also consuming the event, so it cannot trigger any other rules.
- Save and close the resource.