# Implementing the initial step

## Implementing the initial step

![](/files/-M-FWZXPoGMA--Pbh5qv)

![](/files/-M-FWZXR3F_iA4akNUFk) ![](/files/-M-FWZXTKD6c5SeZYMro)

![](/files/-M-FWZXVaRNNfoW1_AqW)

![](/files/-M-FWZXXL9ADY-Z4ZIBK)

![](/files/-M-FWZXZViUgesjbDQ89)

![](/files/-M-FWZXa5-TZawL9-L7z)

![](/files/-M-FWZXcN-ZGamVAJHFX)

![](/files/-M-FWZXeIF2UJO6hEetS)

![](/files/-M-FWZXgcatknYoJu_KZ)

![](/files/-M-FWZXiwC8HbQ1l6Ffw)

![](/files/-M-FWZXkddggwHrVreFx)

![](/files/-M-FWZXmVkigZ2WnYdAL)

![](/files/-M-FWZXoUJX6ay7bhtod)

![](/files/-M-FWZXqSr2wjobZCFix)

![](/files/-M-FWZXst5OhrH2Bkrb3)

Then you shall obtain the rule as follows. Notice that the stringValue of the calculatedAttribute as a formula. So you should select the formula not a litteral. And also that we had to create a binding varialble "bd" for attribute birthdate of call Person.

![](/files/-M-FWZXur7DOR-1nFlMk) Notice that we test there is not already a calculated attribute for that person with the same key

Notice that we have to add to the list of calculated attribute of the person and then tell the rule engine the list was updated.

## Test the initial step

The workbench allows to test the rule we do. Create a new item of type "Test scenario" like follows :

![](/files/-M-FWZXwoci_c9ao_cvT)

![](/files/-M-FWZXywAB9GqdDwwyf)

![](/files/-M-FWZY-MUqDlPgFq3h7)

Click on the "Given" Cross and add a new fact as follows :

![](/files/-M-FWZY10ral9pGnN9-S)

Then click on the "Add Field" text.

![](/files/-M-FWZY3P5ItA6e4INcg) Select the field "quoteDate" :

![](/files/-M-FWZY56LDKciQU4nVG)

Click on the "Literal value" button

![](/files/-M-FWZY7p2mdRAQcWOlw)

As the attribute is of type date, you can select a date with the date picker.

![](/files/-M-FWZY9aXNEC1woGS5Y)

Select a date and then add another instance of type Person

![](/files/-M-FWZYBxVKqKIBhaubA) and add a field and select birthdate. ![](/files/-M-FWZYD9gFQa8Ut9Ozs) Select literal value.

![](/files/-M-FWZYFVUPDaj2CidWn)

And select a date as for the quote date but on same day (here June 30th? ![](/files/-M-FWZYHpKJ3Q6woRhsn) then add a expectatation by clicking on the Cross near Expect ![](/files/-M-FWZYJJywZeMSHDGo9)

Add a fact of type CalculatedAttribute

![](/files/-M-FWZYLYz-EHS4I9aiA)

and Click on the "A fact of type... " Then chose the StringValue field

![](/files/-M-FWZYNpIHpLb7X8en1)

And then enter the value true

![](/files/-M-FWZYPxBDVNeWvdqYB)

And as the rule we want to test is in ruleflow group init. Click on the cross near the "Given" cross and enter "init" in the activate rule flow group part.

![](/files/-M-FWZYR1HW-mWtGu3GA)

The test scenario should then look like this :

![](/files/-M-FWZYTlMdGCcO0Ixvz) Then click the "Run scenario" button twice and you should see the screeen as follows ![](/files/-M-FWZYVNNnc7Uxy9516)

## Calculate person age

We shall calculate the person age based on his birthday and the curDay attribute of the quote. At the same time, we shall initialize the price attribute with a BigDecimal. in the function.drl, add the "import java.math.BigDecimal"

![](/files/-M-FWZYXlu0uPK-zAjWn) First add the two classes on which we shall apply the rule. ![](/files/-M-FWZYZkF9x0HPeKOPR) Then we should create the rule like that.

![](/files/-M-FWZYaAnAzESX8oHEB)

We added two options : the ruleflow group.

Then we can create a test scenario to verify our rule.

![](/files/-M-FWZYc5NW0ZGxxn_C-)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nicolas-heron.gitbook.io/droolsonboarding/brms/implementing_the_inital_step.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
