Sei sulla pagina 1di 29

DECLARATIVE RULES

1 of 29

Contents
Declarative Rules
Forward Chaining
Backward Chaining
Declarative Rules Type
Validation
Rules Inspector

Duration 2:00 hrs

(All the screenshots are taken from PRPC 5.1)


2 of 29

Extracts from Exam Blue Print


Understand the difference between procedural and declarative
program models
Identify the different declarative rule types and their functions
Understand the difference between forward and backward chaining
Understand the concept of page context in Declare Expressions and
Constraints
Understand how to use function rules in Declare Expressions
Explain how dynamic calculation occurs with Declare Expressions
Understand how to combine Declare Expressions with decision tables
to create complex decision functions

3 of 29

Declarative Rules
Allow for dynamic processing of property values
Do not need to be explicitly called
Are not run in a sequential fashion
System manages re-evaluation when it detects change

Difference between Procedural and Declarative model


In the procedural model the developer decides when a piece of

processing needs to happen, writes the code and explicitly calls it


in the appropriate situation to invoke that processing.

In the declarative model, PRPC automatically invokes that rule

whenever appropriate, depending on the rule type.

4 of 29

Forward Chaining
Forward Chaining
Forward chaining is an internal mechanism that provides the automatic
propagation of changes in one property value to changes in other
property values or to indexes.
For E.g.:
When an activity step changes the value or a property that is defined in

such rules, the system automatically consults an internal dependency


network to see if other values are affected, and performs property value
computations, indexing, and other processing as determined by the
network. This is known as forward chaining.

Process commander often recomputes the target property values

automatically each time the following occurs

Any of the other values in the expression change

Whenever value for this property is accessed

Based on other criteria


5 of 29

Backward Chaining
Backward Chaining
Process Commander allows a computation to advance even when the

value of an input or parameter property is not available.

Property-Seek-Value method can analyze declarative rules to

determine a missing property

For E.g.:
A load calculation requires the current prime rate to complete the
calculation. If the value is not available on the clipboard, the system
looks for the value using a web service connector. If that fails the
system is directed to an external database where the rate can be
retrieved. If that fails, the user is prompted to enter the current
value.

6 of 29

Declarative Rules Type

7 of 29

Declarative Rules Type


Declarative Rules

Rule Type

Constraints

Rule-Declare-Constraints

Declarative Expressions

Rule-Declare-Expressions

Declare Index Rules

Rule-Declare-Index

Declare OnChange rules

Rule-Declare-OnChange

Declare Triggers

Rule-Declare-Trigger

8 of 29

Declarative Rules Type.


Constraints
Constraints rules can provide an automatic form of property

validation

Every time the property's value is "touched", in addition to the

validation

Provided by the property rule or other means. The system evaluates


Constraints automatically each time a property identified in a

Constraints

Rule is changed. This technique is known as forward chaining.

Constraints

Use the forward chaining. For example we can create a constraint for

multiple properties to see that all amount are positive.


Are listed in Decision rule category.

9 of 29

Declarative Rules Type.


Constraints Contd

10 of 29

Declarative Rules Type.


Declare Trigger
A trigger rule identifies an activity that runs automatically whenever an
object of a particular class is saved in or deleted or updated from the
database.
Trigger implements Forward chaining
Are listed in Decision rule Category

11 of 29

Declarative Rules Type.


OnChange
Declare OnChange rules can be used to run an activity automatically

at activity step boundaries whenever the value of a specified property


changes. This capability provides a form of automatic forward
chaining. If you specify more than one property, they all must be on
same page. For example, we can create a declare OnChange to call an
activity that send a mail to employee when ever either HRA or Basic or
Special Allowance are changed.

Are listed in Decision rule category

12 of 29

Declarative Rules Type.


Declare Index
Declare Index rule are defined for defining criteria under which
Process Commander automatically maintains index instances for
faster access
Can improve search and reporting access for properties that can
not be exposed as individual database columns as they are
embedded within repeating group
Listed in the SysAdmin rule category

13 of 29

Declarative Rules Type.


Declare Expressions
Used to define automatic computation of property
values based on expressions
Are listed in the Decision rule category.
A Declarative expression always targets a single property, which is
the output of the expression statement.
An expression can also call a decision Trees, decision tables and
Map values.

14 of 29

Declarative Rules.
Target property and Page Context
A target property is the address of a property name-value pair on
the clipboard, in the context of a change to the value.
If the name-value pair does not already exist at that address, the
system creates it, using the name of the property (part of the
address) and the class of the page to locate the Rule-Obj-Property
rule defining the property.
Page Context :
The default page context for declarative rule is the current work
object page(pyWorkpage)
To access a property in an embedd page (Page list) you must
change the page context of the declarative rule.

15 of 29

Declarative Rules.
Pages and classes tab of declarative expressions
Used to list the pages referenced in the expression tab
Is populated automatically when creating a declare expression based

on a page type property

Values in the Page Name fields Can be used in expressions to

reference a particular page easily

Top Page is used to reference the top page within a set of embedd

pages

Parent Page is used to reference the immediate parent page within a

set of embedd pages.

16 of 29

Declarative Rules.
Dynamic Calculation
Allows automatic re-computation and redisplay of all declare
expressions target properties appearing on the form. This is done
using AJAX Technology.
It need to enabled on Harness by checking the Enable Expression
Calculation checkbox.

17 of 29

Rules Inspector

18 of 29

Rules Inspector
Rules Inspector
Is a tool that provides an easy way to locate rules present in User

Interface.

Can be used to display the Harness being used, section being used,

properties being displayed on the sections and declare expression rules


that are automatically calculating property values.

It also cause the dependency network analysis tool to open

Clicking the properties allows you to enter values for testing.

19 of 29

Validation

20 of 29

Validation
Ensures that data inserted into the application satisfies
predetermined formats and other defined input criteria
Client-Side Validation
The format of many user inputs on a flow action form or work
object form can be tested on the user's workstation, before the
form is submitted to the application server that hosts Process
Commander. This feature is known as client-side format
validation
Server-Side Validation
Processing takes place on the server.
User enters data into a field
User makes a request to move to next step
Request is sent to server
Data is then validated on the server, if valid data then user
proceeds to next step else user is not allowed to proceed.
21 of 29

Validation.
Standard Validate Rules
Two standard validation rules called by default

OnAdd
Is called when a new work object is created

Validate
Is called whenever there is a transition from one step to

another in a business process.

22 of 29

Validation.
Server-Side Validation: Constraints Rule
Allows a comparative relationship to be defined between property

values that is expected to be true at all times

If the constraint is not met, a message is displayed and the page is

marked as invalid

Are listed in Decision rule category

Multiple Constraints:
Each row defines a separate constraint
Order is not significant as each constraint processed independently
Use expressions in the When and Require that conditions to perform

more complex processing.

23 of 29

Validation.
Server-Side Validation : Edit Validate Rules
Use the Edit Validate form to define a Java routine that tests the

validity of an input value in an activity that processes user input. The


activity calls the Property-Validate method, which applies the test
defined in an Edit Validate rule.

Typically, the input value arrives from a user who completes an HTML

form, but it may also arrive through an interface with an external


system.

Normally whenever user input fails such processing, the input is

rejected and a red X mark appears next to the input field in error.
Messages may convey more about the error and the suggested
remedy. The user can change the input and resubmit the form.

They are referenced in Property Rules and Validate Rules

24 of 29

Validation.
Immediate Validation Processing
Allows server side validation rules to be processed without
refreshing the screen

Uses AJAX

Must be enabled on the harness

25 of 29

Added Information
For more information you can refer the below links.
Declarative processing
http://pdn.pega.com/DevNet/eLearning/DE1/50226.asp
Declarative Expression Example
http://pdn.pega.com/DevNet/eLearning/DE1/50227.asp
Declarative Expressions and Forward Chaining (01:30)
http://pdn.pega.com/DevNet/eLearning/DE1/50228.asp
Declarative Expressions and Backward Chaining (01:55)
http://pdn.pega.com/DevNet/eLearning/DE1/50229.asp

26 of 29

Added Information

Backward Chaining Example (01:02)


http://pdn.pega.com/DevNet/eLearning/DE1/50230.asp
When to Use Declarative Expressions (00:36)
http://pdn.pega.com/DevNet/eLearning/DE1/50231.asp
Declarative Expressions Best Practices (01:13)
http://pdn.pega.com/DevNet/eLearning/DE1/50239.asp

27 of 29

Summary
This topic familiarized us with :
What are Declarative Rules.
Forward Chaining and Backward Chaining.
Different types of declarative rules.
Rules Inspector.
Types of Validation.

( Complete the Lab Exercise of this topic.)

28 of 29

Thank You

29 of 29

Potrebbero piacerti anche