Questionnaires - Dynamic values


Definition

A dynamic value enables you to define a dynamic condition or a constraint for questions based on the results of SQL queries that are run when the variable is called.

EndDefinition

example  Arrival date greater than or equal to the current date

Example

Define a constraint to ensure that the appointment date falls within 15 days following the current date.

1. Create the @now dynamic value in the reference table. The query evaluates the current date and time when the variable is called.

2. Associate the dynamic value with the questionnaire.

3. Define a constraint for the Appointment date Example - Date entry.png question via a comparison with the @now dynamic value. An error is generated if the date entered by the user is greater than "@now + 15 days"

4. When the questionnaire is run:

  • The @now value is evaluated and is equal to the current date.
  • If the user enters an appointment date that is not within 15 days following the current date, an error message will appear, The appointment date must be within 15 days from today.

Notes

  • The @ character automatically precedes each variable.

example  @now: Current date and time

  • The list of dynamic values is provided by EasyVista. You cannot delete the values.
  • A dynamic value can be associated with several questionnaires. If the link between a given dynamic value and a questionnaire is deleted, this does not affect its links with other questionnaires.
  • If the type of a dynamic value is modified in a questionnaire, its link with constraints or conditions will automatically be deleted.

Caution

  • If you modify the type of a dynamic value that is being used in a condition or constraint, its link with this condition or constraint will automatically be deleted.

Best Practice

  • In List mode, the default view is Questionnaire. If no dynamic value is associated with a questionnaire, you should use the List view.

Menu access

  • References > Other references > Questionnaires: Dynamic Values
  • In a questionnaire, select the Manage Questions wizard > Create a new dynamic value

Screen description

 Dynamic value editor.png

Name: Unique ID of the dynamic value.

Type: Type of dynamic value. The possible values are String, Date and Time, Decimal and Duration.

Description: Description of the dynamic value.

Content: SQL query run when the dynamic value is called for a question. Open url.png See the examples of SQL queries.

Procedure and Wizards

How to create a dynamic value

1. Select Operation > References > Questionnaires: Dynamic Values  or  Transition > References > Questionnaires: Dynamic Values.

2. Click Add icon.png and specify the information on the new dynamic value.

3. Click Save.

The new dynamic value will be available for all questionnaires regardless of the menu in which it was created.

How to use dynamic values in a questionnaire

Step 1: Associate dynamic values with the questionnaire

Note: As dynamic values are calculated when the questionnaire is run, you should associate only those you want to use for conditions or constraints in questions.

1. Open the questionnaire you want.

2. In a multi-section questionnaire, go to one of the sections.

3. Select the Manage Questions wizard.
        Manage the questions wizard.png

4. Click Assign the dynamic values.

5. Click Add icon.png to select the dynamic values you want.

     Notes:

  • The list will display the values already associated with the questionnaire.
            Dynamic value association.png
  • If you create a new dynamic value directly in a questionnaire, it will automatically be associated with this questionnaire. It will also be added to the reference tables and will be available for all questionnaires.
     

Step 2: Define constraints and conditions for questions

Definition of a constraint

1. Click Constraint icon.png or No constraint icon.png in the Constraint column of the question.

2. Select Compared to a Dynamic Value from the Option drop-down list.

3. Enter the condition or value applicable.

Note: Only dynamic values whose type is identical to the question will be available.

Definition of a condition

1. Click Condition icon.png or No condition icon.png in the Condition column of the question.

2. Select one of the four options available: Contains/Does not contain the dynamic value, Starts with/Does not start with the dynamic value.

3. Enter the condition or value applicable.

Notes:

  • Only dynamic values whose type is identical to the question will be available.
  • You can use regular expressions. Open url.png See the examples.

When the questionnaire is run via a workflow, each dynamic value will be evaluated in the constraints and conditions using it.

Wizards

Update
Delete

Examples of SQL queries

  • Return the first day of the previous month ==> 1stDayOfLastMonth variable
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, DATEADD(MONTH, -1, GETUTCDATE())), 0)
  • Return the first day of the next quarter ==> 1stDayOfNextQuarter variable
SELECT DATEADD(QUARTER, DATEDIFF(QUARTER, 0, DATEADD(QUARTER, 1, GETUTCDATE())), 0)
  • Return the last day of the current month ==> lastDayOfTheMonth variable
SELECT DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, DATEADD(MONTH, 1, GETUTCDATE())), 0))
Tags:
Powered by XWiki © EasyVista 2022