Conditioning and dynamic contens (OGNL)

Openforms offers the possibility of controlling contents and documents dynamically using conditions. The 'Object-Graph-Navigation Language' or OGNL is used for this purpose.

Boxes with the descriptions 'visibility condition' and 'condition' can be found in different spots of the openforms surface.

         

These boxes can be used in order to index-link forms or to ensure an action is carried out only under a certain condition.

e.g. :

  • Index-linked appearance of question groups (can contain any kind of input field or content) 

    Example: There is a selection by means of a radiobutton. Option 1: I want to make an appointment, Option 2: I would like to make a written request. In the case of option 1 a window with a datepicker, which will allow you to select an appointment, as well as two boxes which will allow you to specify the time will open. In case of option 2 two text boxes will open; one for entering a subject and another for entering a message.

  • Conditions/Regulations for manually determined error code

    Example: In the form there is a box reserved for stating an e-mail address as well as a box for stating a phone number. The customer must fill in at least one of both boxes in order to complete the form.  

  • Controlling the following pages
    Example:
    An interface decides whether a customer may purchase a certain financial product. Depending on the interfaces assessment, different pages will be displayed following the process.

  • Index-linked placeholders in texts/e-mails etc.
    Example: After the completion of a form an e-mail is sent to the customer. The e-mail is meant to be personalized. The client is addressed with the name given in the form.

  • Controlling e-mails
    Example: An e-mail is sent to the client after the closure of a product sale. The e-mail differs in content, depending on whether it is being sent to a regular customer or a new client.

 

Examples for further explanation of typical Use Cases:

Index-linked appearance of question groups (can contain any kind of input field or content)
An explanation (text) that matches the option selected by the user is to be displayed:

There is one single choice question asking the user whether he/she prefers red or blue. An according text is to be displayed depending on their answer. First of all a single choice question with two answers and two additional textblocks was created. The question was assigned the paragraph-ID 'color'. The answering options were assigned 'red' and 'blue' as an ID. The according textblock received the visibility condition OGNL: value('color')=="blue"

Configuration

View


 

Conditions/Regulations for manually determined error code.

A form shows two possible textboxes (e-mail and/or phone) to establish customer contact. One of the two must be entered in order to move on to the next page.

Two textboxes (e-mail and phone) are created, as well as one text block which is configured as an error code.

The OGNL order as a visibility condition for the error code is:

OGNL: !isset('phone') && !isset('email') 

as a result of this code isset verifies whether a value was set. The exclamation mark before the issed negates the order, i.e. isset verifies that a values was not set. As the error code is to be displayed when both boxes are empty, the two checks are connected with a logical AND (&&).

Konfiguration

Ansicht

 

oder

 

 

Controlling subsequent pages

There are UseCases in which  different pages are to be displayed to the user due to interface results or the user's own statements. Generally pages of a form can be skipped depending on conditions that established with an OGNL order, using the function 'subsequent pages'.

In our example a decision is made on the first page of a form (red or blue). Depending on this decision, the user will be redirected to a different subsequent page. This means there are two variations in which the form can unfold:

  1. page 1,page 2, end page
  2. page 1, page 3, end page

If no following page is determined, openforms displays the pages in the order in which they were created. This means for variation 1 the end page is determined as the page following page 2.  This following page can be set without determining any conditions, as the end page is to be displayed in any case. In variation 2 a conditional following page from page 1 to 3 must be installed. A conditional following page from page 3 to the end page is not necessary, as it follows automatically in the structural order.

 

A subsequent page can be crated above the contents on each page (exception: last page):

Follow-up pages that have already been defined are displayed in this area and can be edited using the pen symbol. The bin symbol removes the selected follow-up page. The arrows position the execution of the follow-up pages.

After clicking on "Verweis setzen" a window will open automatically. On this page the follow-up page can be selected to the left hand side. To the right hand side in 'further properties' the OGNL order can be entered into the box 'conditions'. 

 Seite 1  

   

                                                        

Seite 2                               oder                                                                    Seite 3

                                                             

Abschlussseite     

Index-linked placeholders in texts/e-mails etc.

It is possible to insert placeholders that insert the according data into the text during run time into all content-filled elements.

Placeholders within a text begin and end with %%. An OGNL order which inserts text blocks into the continuous text can be placed between the percentage signs.

Besides replacing a normal continuous text the placeholders can also be inserted instead of an e-mail recipient.

 

The word 'e-mail' reflects the paragraph ID of the request. An automatic e-mail can thus be sent to the e-mail address in the form, e.g. as an order confirmation to a client.

In the example  below a personalized summary page was included. The command "%%OGNL: value('title') == "Mr." ? "Dear Mr." : "Der Mrs." + value('first name') + " " + value('surname')%% you have made the following entries in the form:" 

Title: It is verified whether the participant has selected Mr. or Mrs. Accordingly the order will write out 'Dear Mr.' or 'Dear Mrs.'

First and surname: By means of the paragraph ID the values put into the text boxes will be inserted.

 

Most important OGNL commands:

 

Command 
!Each OGNL command can be negated, i.e. the exact opposite of the command at hand must be fulfilled. e.g.: OGNL: !isset('paragraph-Id') > as long as the value paragraph ID has not be set, the conition is met.
OGNL: value('Absatz-Id')

Outputs the paragraph ID value

OGNL: formattedValue('Absatz-Id')Outputs the 'visible' content. This means that e.g. in a box for the selection of a country, a list of country codes (abbrevations) is usually deposited. The abbreviation is written into the ID, this command is however used, when the name is requested. 
OGNL: isset('Absatz-Id')Verifies whether a value has been set.
OGNL: ValueForMappingAndKey('Kontext', 'Anker')Outputs the value of an ancor. The value from the is pulled from the document with the 'Kontext'. (i Apple Plits Formate )

OGNL: otDiffYearsBetweenDates(Ankerdatum2,AnkerDatum1)

Outputs the year margin (with one decimal place, i.e. month). The command can be extended at will with a comparison e.g.  <= or ==
OGNL: value('title') == "Mr" ? "Dear Mr " : "Dear Mrs " + value('first name') + " " + value('surname')Verifies whether 'Mr.' has been selected and outputs Prüft ob im Feld Anrede "Herr" ausgewählt wurde und gibt dann Dear Mr. First Name as a result. If 'Mr.' has not been selected, it outputs Dear Mrs Dirst name Surname
OGNL: datenuebertragen.response.checkStatus.statusCode == "3"It is verified, whether the value 3 has been returned in an interface for the key "statusCode" in the dictionary.
OGNL:formattedValue('geburtsDatum', '%Y%m%d')Outputs the indeicated value within the paragraph ID "geburtsDatum" in the desired format
OGNL:isset('aktTitel')?"Titel : "+value('aktTitel'): ""When a value is indicated in "aktTitel' it is released as title: Dipl. Ing.. If no value has been entered, there is no output.

OGNL linking commands

  • && when both conditions have to be met
  • || when only one condition has to be met
  • <OGNL Befehl> ? <OGNL Befehl oder "Text"> :  <OGNL Befehl oder "Text">  results in an if-then relationship