A080 – Create a constraint on an object

What you will learn ?

How to add a constraint on a business object. A constraint is a business rule (If “condition” then “impacts”) on an object based on its contextual data and user rights.

STEP 1: Access

To add a constraint on an object, you have the choice :

  • Open the object and go on the constraint tab to list the constraints of this object
  • Or go the Administration / Constraint menu to list all configured constraints

Exercise:

The constraint to create is : The main address of the customer is required when it is of customer type.

  • Open AppClient object and go to the constraint tab
  • Click the Create button on the top left of the list

STEP 2: The constraint

To create a new constraint :
a) Enter a unique name for the constraint: the constraint is conventionally prefixed by the name of the object
b) Select the object if it is not filled (when access from the menu)
c) Enter order to constraint: if the object has several constraints, it will apply in ascending order.
Constraint are numbered 10 to 10 in order to insert later.
d) Choose a type of constraint:

  • Expression: the constraint will apply if the condition of the criteria is true
  • Field: constraint will apply depending on a Boolean field of the object (usually a calculated and hidden field)
  • Method: for a complex use a method name of the object that will return a Boolean, this method will be to code specifically
    e) Depending on the type, enter expression, the field or the name of the method to call
    f) Enter the effects :
  • Static: the constraint is applied once at the first load of the object
  • Front-end: constraint will apply on the front (client side)
  • Back-end: constraint will apply on the back (server side)
    Constraints can be executed both on front and back end.
    g) Finally, Enter the module

Save the form without quit.
NB: the syntax of an expression is based on a JavaScript expression in which it is possible to add Simplicité keywords between brackets, usually:

  • []: to return the field value in the context of use
  • [FIELD:].getValue() access to field and all these methods ex. getValue.
  • [ISNEW]: true if the form is being created
    Example of expression: [ISNEW] && [soldeClient] <100 && grant.hasResponsibility(“MANAGER”)
    that is to say, the constraint will apply only if it is updated, the customer balance is less than 100, and the user is manager.

Exercise:

Create constraint with

  • Name = AppClientAddress
  • Order = 10
  • Type = Expression
  • Expression = true (indeed the constraint will apply all the time)
  • Effects = Front-end and Back-end
  • Module = MyModule

STEP 3: Create an impact

Fill in the form of impact:

  • Select the type of impact either on the object or on an field
  • If the impact is an field, select the field concerned
  • Choose a property from the impact in the list (required, visible, editable …)
  • Enter an order of impact: if there are several impacts they will be applied in ascending order
  • Enter an expression that returns the property value
  • Choose a module
    save / close the form to return to the constraint.

Exercise:

It should make it mandatory to open only if the type is CTM.
To do this, create an impact:

  • The field cliAdresseFK: this is the link to the address to be mandatory or not
  • Property of the field “Mandatory”
  • Expression = [cliType].equals("CTM") which returns true if the type is CTM We could create other very similar impacts to make the invisible address or read-only, by just changing the property.

STEP 4: Grant constraint

Constraints are public by default, so if nothing is specified in this step, it will be applied to all users (designer included).
It is possible to grant constraints to some profiles (rights groups).
For example, one group may not be able to see all of an object, while an administrator group accesses all.

Exercise:

From the constraint grant tab :

  • Click Create (on the top left of the list)

STEP 5: Create grant constraint

Fill out the form:

  • Select a Group
  • Indicate whether the grant is active or not
  • Choose a module
  • Save / Close

Exercise:

Grant the application group MyAdminGroup to AppClientAddress constraint.

STEP 6: Clear cache

To activate the constraint, it is necessary to clear the cache of the platform:

  • Click on the shortcut Clear Cache
  • Action Clear all sessions on all server caches
STEP 7: Test and validate

STEP 7: Test and validate

Exercise:

After clearing the cache, test and validate with a customer type Customer

A070 – Physical data model

Using the graphical diagram view to see physical data model.

A090 – Help on a business object

How to add help messages on business objects:

  • Static Help
  • Contextual help
  • Help on fields