As you create applications with InputStudio, for sure any application you create may need to execute some code at objects creation, update or saving. InputStudio allows you to provide some code snippets to your applications in the way of Business Rules objects as code expressions.
All Business Rules (expressions) must have a name, the actual code expression and when they will be applied (at creation, update or saving).
The code expression itself is build up from the attribute name, a mathematical operator and the actual value.
As you can infer from this, any code expression is the assignment of a value to an attribute. The actual attribute names are automatically filled up by InputStudio so, you just have to pick one from the list.
As you noted from the operators screenshot (below image) you can also use operator + equals which means the attribute will be sum/substract/multiplied/divided/modulus to its current value.
In the construction of this code expressions InputStudio helps you by discovering your data entities and its attributes and by suggesting them in the expressions list picker. This feature helps you a lot since you don’t have to know and type each of your data entities and its attributes. Also, some other available methods or properties of your data entities (inherited from its base class) are suggested like:
- <DataEntity> is your actual data entity name
- ordinalIndex is a numeric index number
- <Attribute> is your actual attribute name
- Average, Min, Max and Sum are aggregate functions which calculate its values based on the data entity children objects.
While you can just select from the available objects, methods or properties, you can also type any other mathematical expression made up from numeric constant values or a mix of available object attributes multiplied, sum, subtracted or divided by some constant value or another object attribute.
The Gold Parser.
Note: Following screen-shots and code, explain a little bit how the evaluation of expressions was accomplished in InputStudio. For your actual code snippets you don’t need this.
Then some helper code implements that grammar which at the end evaluates the Business Rules expressions.
Test expressions code testing in InputStudio project.
That is it for now, hope this post gives you an insight on the grammar you can use when coding your Business Rules snippets.