Adding the CreateAccount Rule
The
BadCreateAccount
rule has a higher priority, so it will fire before the
CreateAccount
rule.
- Procedure
- Right-click the Rules folder again, and select .
- In the
New Rule Wizard Rule name field, type
CreateAccount
. - Click Finish.
- In the
Form tab, set the
Priority field to
5
. (This is a lower priority than theBadCreateAccount
rule.) - Drag the
CreateAccount
event from the TIBCO BusinessEvents Studio Explorer tree into the first empty row in the Declaration section.This rule has no conditions — the
BadCreateAccount
rule means there is no need. You could have combined the two rules into one. There are many ways to write rules for a project. You have to use your judgment.In the Actions panel, you’ll use an ontology function to create the Account concept instance. You can also get to ontology functions using the function catalog.
- From the top menu select
The Catalog Functions view displays on the right (unless your Eclipse IDE is configured differently — it could display along the bottom, for example).
.
- Below each concept, event, and rule function is its ontology function. Expand :
- Drag the Account function into the Actions section.
You see its signature:
Concepts.Account.Account(/*extId String */,/*Balance double */,/*Debits double */,/*Status String */,/*AvgMonthlyBalance double */)
- Configure the function to create the Account concept, and type the rest of the actions as follows. You can double-click the tab to expand the rule editor, to make rule writing easier.
Concepts.Account.Account(createaccount.AccountId/*extId String */, createaccount.Balance/*Balance double */, 0/*Debits double */, "Normal"/*Status String */, createaccount.AvgMonthlyBalance/*AvgMonthlyBalance double */); Event.consumeEvent(createaccount); System.debugOut("#### Created account " + createaccount.AccountId);
- Save and close the resource.
Note that in this case it is not really necessary to consume the event. No other rules have this event in their scope.
Events with time to live (TTL) set to zero (0) are consumed at the end of an RTC. However, it does no harm and makes the rules more consistent, reducing chances of error.