Wiki source code of Saisie de données

Last modified by Aurelie Bertrand on 2026/06/26 15:03

Hide last authors
abertrand 19.1 1 {{ddtoc/}}
2
Aurelie Bertrand 106.1 3 ----
4
Aurelie Bertrand 120.1 5 = Preamble =
crandon 6.1 6
Aurelie Bertrand 120.1 7 The purpose of data entry is to add new data via a form displayed on the dashboard.
crandon 6.1 8
Aurelie Bertrand 120.1 9 The principle involves creating a form that automatically generates a table in a relational database such as MySQL, PostgreSQL, MariaDB, H2 or Oracle.
crandon 6.1 10
Aurelie Bertrand 120.1 11 The data entered by the end user will be stored in this table; it will therefore be possible, via Studio, to create a data model based on this table.
crandon 6.1 12
Aurelie Bertrand 120.1 13 = Configuring data entry =
crandon 6.1 14
Aurelie Bertrand 120.1 15 To use this feature, you must configure it via the **Server Settings > Databases >[[Data Entry>>doc:Digdash.deployment.configuration.configuration_guide.data_entry.WebHome]]**[[.>>doc:Digdash.deployment.configuration.configuration_guide.data_entry.WebHome]]
crandon 6.1 16
Aurelie Bertrand 120.1 17 This interface allows you to enable the feature and select the database in which the data entered will be stored.
crandon 6.1 18
Aurelie Bertrand 74.1 19 [[image:Data_entry_configuration_FR.png||alt="Configuration saisie données"]]
abertrand 14.2 20
Aurelie Bertrand 120.1 21 You can select the default database, which is an H2 database. This database is not a production database, so we do not recommend using it.
crandon 6.1 22
abertrand 14.2 23 (% class="box warningmessage" %)
24 (((
Aurelie Bertrand 120.1 25 ⚠ Only MySQL, PostgreSQL, MariaDB, H2 and Oracle databases are supported.
abertrand 14.2 26 )))
crandon 6.1 27
Aurelie Bertrand 120.1 28 = Create a form =
crandon 6.1 29
Aurelie Bertrand 91.1 30 (% class="box infomessage" %)
31 (((
Aurelie Bertrand 120.1 32 💡 You can find more information about components in the documentation [[https:~~/~~/help.form.io/userguide/form-building>>https://help.form.io/userguide/form-building]].
Aurelie Bertrand 91.1 33 )))
34
Aurelie Bertrand 120.1 35 Once the feature has been enabled and configured, you can create one or more forms.
crandon 6.1 36
Aurelie Bertrand 120.1 37 To do this:
crandon 6.1 38
Aurelie Bertrand 120.1 39 1. Log in to the dashboard editor and click on **‘Forms’** in the left-hand panel listing the items that can be added to the dashboard.
Aurelie Bertrand 79.1 40 [[image:Data_entry_new_form_FR.png||alt="Nouveau formulaire"]]
Aurelie Bertrand 120.1 41 1. Then click the **New form** button.
42 ➡ The form creation interface will then appear.
crandon 6.1 43
Aurelie Bertrand 72.1 44 (% class="box infomessage" %)
45 (((
Aurelie Bertrand 120.1 46 ℹ This interface is only available to users with the**Dashboard > Create a form** permission.
47 To save the form, the user must have:
Aurelie Bertrand 107.1 48
Aurelie Bertrand 120.1 49 * the **‘Studio > Manage Common Elements’**permission if the permission group is assigned at user level.
50 * the**Studio > Manage Role Elements** permission if the permission group is assigned at role level.
Aurelie Bertrand 72.1 51 )))
abertrand 38.2 52
Aurelie Bertrand 120.1 53 Here is the form creation interface:
crandon 6.1 54
Aurelie Bertrand 79.1 55 [[image:Data_entry_new_form_page_FR.png]]
crandon 6.1 56
Aurelie Bertrand 120.1 57 1. In the **Properties** section, enter**the** Form**ID**: this corresponds to the name of the table created in the database. This ID must be unique and must contain only alphanumeric characters.
58 1. Enter the **Form Name **: this corresponds to the name of the form displayed in the various interfaces.
59 1. The **Role **field **allows you **to restrict access to the form to a specific role. See the section [[Securing a form>>doc:||anchor="Sécurité_form"]] for further details.
60 1. The **‘Sharing’ **field **allows you **to restrict access to the form to a user profile or define a custom sharing setting. See the section [[Securing a form>>doc:||anchor="Sécurité_form"]] for further details.
61 1. In the **Content** section, define the form fields: drag and drop the required fields from the list of different field types (on the left) into the input form (on the right).
62 ➡ For each field added, a field configuration window appears. See the section [[Configuring form fields>>doc:||anchor="Configuration_champ_form"]] below for further details.
crandon 6.1 63
abertrand 34.2 64 (% class="box infomessage" %)
65 (((
Aurelie Bertrand 120.1 66 ℹ A form must contain **at least one field and a button** to submit the data.
abertrand 34.2 67 )))
68
Aurelie Bertrand 79.1 69 [[image:Data_entry_form_example_FR.png]]
70
abertrand 34.5 71 (% start="5" %)
Aurelie Bertrand 120.1 72 1. Once all the fields have been added to the form, you can save it by clicking **OK** at the bottom of the form.
73 ➡ A table named after the form’s ID is created in the database.
crandon 6.1 74
Aurelie Bertrand 120.1 75 You can edit, move, copy or delete a component using the toolbar that appears when you hover over the component with the mouse.
abertrand 39.2 76 [[image:Editer_composant.png||alt="Edition_composant"]]
77
78
Aurelie Bertrand 120.1 79 When you save the form, the table will be updated automatically. However, it is not possible to change a field’s data type (e.g. changing from a Date field to a Number field).
abertrand 34.5 80
Aurelie Bertrand 120.1 81 This table will contain all the fields present in the form, as well as the following columns:
abertrand 34.5 82
Aurelie Bertrand 120.1 83 * **a unique identifier ( **automatically incremented) enabling data to be edited (its name is id_form_id).
84 * **dd_user**: the ID of the user who added or modified the record
85 * **creation_date**: the date the data was created
86 * **modification_date**: the date the data was modified
abertrand 34.5 87
Aurelie Bertrand 120.1 88 Deleting a form will result in the deletion of the table and the data it contains.
abertrand 34.5 89
Aurelie Bertrand 120.1 90 == Configuring form fields{{id name="Configuration_champ_form"/}} ==
abertrand 34.5 91
Aurelie Bertrand 120.1 92 When adding a field, a field configuration window appears. This interface has several tabs and allows you to configure both the field’s display and its behaviour within the form.
abertrand 34.4 93
Aurelie Bertrand 85.1 94 (% class="box infomessage" %)
95 (((
Aurelie Bertrand 120.1 96 💡 You can get help on the current component by clicking the **Help **button **in the **top right-hand corner of the configuration window.
Aurelie Bertrand 85.1 97 )))
98
Aurelie Bertrand 120.1 99 The**Preview** section on the right allows you to preview how the form will look and to save the field’s configuration.
abertrand 34.5 100
abertrand 23.1 101 [[image:Boite_composant.png||alt="Composant"]]
crandon 6.1 102
abertrand 34.4 103 (% class="box infomessage" %)
104 (((
Aurelie Bertrand 120.1 105 ℹ The tabs, as well as the fields and options available for each one, differ depending on the component type.
abertrand 34.4 106 )))
107
Aurelie Bertrand 120.1 108 * The **Display** tab allows you to configure the visual appearance of the field.
109 It includes the following elements in particular:
110 ** **Label**: Choose the label to be displayed in the form (this will also be used as the name of the column in the data table).
111 ** **Input hint / Description**: allows you to add a description or help text for this field to guide the user when entering data.
112 ** **Hidden**: allows you to hide the field, which will therefore not be visible to the end user but will still be present in the form.\\
113 * The **Data** tab allows you to configure the data to be displayed for this field.
114 It includes the following elements in particular:
115 ** **Default value: **allows you to specify the default value for the form
116 ** **Values**: allows you to specify the values from which the user can choose (for drop-down list fields, tick boxes, etc.)\\
117 * The **Validation** tab allows you to configure data validation for this field.
118 It includes the following options:
119 ** **Required: **allows you to make the field mandatory for the user. The form cannot be submitted whilst the field is empty.
120 ** **Unique**: allows you to specify that the value of this field is unique and therefore cannot be entered more than once by the user. If this setting is enabled for several fields, it is the combination of all unique fields that must be unique. When the user edits the field, if its value already exists in the database, the form switches to edit mode and the other fields will be populated with the values stored in the database. In this case, the data submitted will overwrite the existing data.\\
121 * The **Conditional** tab allows you to make the display of this field conditional on the value of another field in the form.\\
122 * The **Logic**tab allows you to carry out advanced configuration to conditionally control and manipulate field parameters, the JSON schema, data values and custom events. It is possible, for example, to secure a form field. See the section [[Security>>doc:||anchor="Sécurité_form"]] section for further details.
crandon 6.1 123
Aurelie Bertrand 120.1 124 === Configuring a ‘Save as Draft’ button{{id name="Brouillon"/}} ===
abertrand 34.4 125
Aurelie Bertrand 120.1 126 You can create a button that allows a form to be saved as a ‘draft’ even if not all fields – including those marked as mandatory – have been completed. To do this:
abertrand 34.8 127
Aurelie Bertrand 120.1 128 1. Drag and drop a **Button** component onto the form.
129 ➡ The button’s configuration window appears.
130 1. Edit the **Label** as required: for example, //Save as draft//.
131 1. From the **Action** drop-down list, select **Save to report**.
132 1. In the **‘Save to state** ’ field that appears, enter //‘draft’.//
abertrand 35.2 133 [[image:Composant_bouton_brouillon.png||alt="Bouton_brouillon"]]
Aurelie Bertrand 120.1 134 1. Configure the other fields/options as required.
135 1. Click **Save** to confirm the Button component’s configuration.
abertrand 34.9 136
Aurelie Bertrand 120.1 137 === Configuring a drop-down list based on the number of items{{id name="Liste"/}} ===
abertrand 35.3 138
Aurelie Bertrand 120.1 139 When a drop-down list is linked to a dimension, the configuration varies depending on the number of members in the dimension.
abertrand 35.4 140
Aurelie Bertrand 120.1 141 1. Drag and drop a **Drop-down list **component **onto **the form.
142 ➡ The button configuration window appears.
143 1. Edit the **Label** as required: for example, //City//.
144 1. Select the **Widget Type:**
145 1*. **ChoicesJS** is recommended** for **dimensions with a large number of items: it includes a search field for server-side searching.
abertrand 50.2 146 [[image:Widget_choiceJS.png||queryString="width=399&height=207" alt="Liste_choicesJS" height="207" width="399"]]
Aurelie Bertrand 120.1 147 1*. **HTML5** is recommended for dimensions with a small number of items: it does not include a search field and, where there are many items, the display may take a long time or the data may be incomplete.
abertrand 50.2 148 [[image:Widget_HTML5.png||queryString="width=427&height=99" alt="Liste_HTML5" height="99" width="427"]]
abertrand 35.8 149
150 (% class="box infomessage" %)
151 (((
Aurelie Bertrand 120.1 152 The number of items displayed in the search field is determined by the value set for **LIMIT_RESULT_SEARCHBOX** under **Configuration -> Server Settings -> Cubes -> Constants**.
abertrand 35.8 153 )))
154
155 (% start="4" %)
Aurelie Bertrand 120.1 156 1. Configure the other fields/options as required.
157 1. Click **Save** to confirm the configuration of the Drop-down List component.
abertrand 35.6 158
Aurelie Bertrand 120.1 159 === Configuring conditional display based on multiple values ===
Aurelie Bertrand 86.1 160
Aurelie Bertrand 120.1 161 It is possible to create a custom condition to automatically display a value based on other values.
162 For example, we have a form containing, amongst other things, a//Status// field and a //Project Name// field. We want to display the value “//Project in progress//” in a text field when the status is “//Active//” and the project name is //“Project1//”. To do this:
Aurelie Bertrand 86.1 163
Aurelie Bertrand 120.1 164 1. Add a text field to the form.
165 1. In the**Component Text Field** window that appears, edit the **Label** as required, then go to the **Logic** tab.
166 1. Click the**Add Logic** button to define the condition.
167 1. Enter the **Logic Name**.
168 1. In the **Trigger** field, select the //JSON Logic// **type**.
169 1. In the JSON Logic editor, enter the following JSON code:
Aurelie Bertrand 86.1 170
Aurelie Bertrand 90.1 171 {{code language="JSON"}}
172 {
173 "and":[
174 {
175 "==":[
176 {
177 "var": "data.f_statut"
178 },
179 "actif"
180 ]
181 },
182 {"==": [{
183 "var": "data.f_nom_du_projet"
184 },
185 "Projet1"
186 ]
187 }
188 ]
189 }
190 {{/code}}
191
192 (% class="wikigeneratedid" %)
193 [[image:Condition_example_FR.png]]
194
195 (% class="wikigeneratedid" %)
Aurelie Bertrand 120.1 196 We then add the action to be performed when the condition defined below is met:
Aurelie Bertrand 90.1 197
Aurelie Bertrand 120.1 198 1. In the **Actions** section, click the **Add an action** button.
199 1. Enter the **Name of the action**.
200 1. Select the **Value** type.
201 1. In the JavaScript editor, enter the value to be displayed in the following format:
Aurelie Bertrand 90.1 202 [[image:Condition_example_action_FR.png||alt="Action"]]
Aurelie Bertrand 120.1 203 1. Click the **Save action**button, then **Save logic**.
204 1. Finally, save the field.
Aurelie Bertrand 90.1 205
Aurelie Bertrand 120.1 206 == Edit / Delete a form ==
abertrand 40.3 207
Aurelie Bertrand 120.1 208 To edit or delete a form, right-click on the form in the **Forms** section of the left-hand panel, then click **Edit** or **Delete**.
abertrand 39.2 209
Aurelie Bertrand 80.1 210 [[image:Data_entry_form_menu_FR.png||alt="Editer/Supprimer formulaire"]]
abertrand 40.2 211
Aurelie Bertrand 120.1 212 = Add a form to the dashboard =
crandon 6.1 213
Aurelie Bertrand 120.1 214 The next step is to add the form to a dashboard page. To do this, simply drag and drop the newly created form onto the dashboard page.
crandon 6.1 215
Aurelie Bertrand 120.1 216 Form objects are configured via the **Settings -> Properties** menu.
crandon 6.1 217
Aurelie Bertrand 120.1 218 == Linking a field to data ==
abertrand 40.4 219
Aurelie Bertrand 120.1 220 It is possible to link a form field to data present on the dashboard. Two types of link are possible:
abertrand 40.5 221
Aurelie Bertrand 120.1 222 * **a link to a dimension on **the dashboard page. This automatically populates the field’s value when that dimension is filtered. It also populates the field’s values with the members of the dimension for selection fields (drop-down lists, tick boxes, etc.).
223 * **a link to a user parameter**. This automatically populates the field’s value with the value of the logged-in user’s parameter. This can be useful for survey-type forms to record which user completed the form.
abertrand 40.4 224
Aurelie Bertrand 120.1 225 To do this:
abertrand 40.4 226
Aurelie Bertrand 120.1 227 1. Click **‘None’ to **the right of the name of the field you wish to link.
228 ➡ The **‘Link’ **box **appears **.
229 1. Select the Link **type**, then the **Dimension or User attribute** to link.
230 1. Click **OK**.
Aurelie Bertrand 82.1 231 [[image:Data_entry_link_FR.png||alt="Lien"]]
abertrand 40.7 232
Aurelie Bertrand 120.1 233 == View a preview of the data ==
abertrand 41.2 234
Aurelie Bertrand 120.1 235 **The ‘Preview data’** option allows you to view a preview of **the data** exactly as it is stored in the database, whilst selecting which fields to display (a **‘Display’** column is added for the form fields). This interface also allows you to manage the data by enabling you to edit or delete a data entry.
abertrand 41.2 236
abertrand 50.2 237 [[image:Aperçu_données.png||queryString="width=735&height=249" alt="Aperçu_données" height="249" width="735"]]
abertrand 41.2 238
239 (% class="box infomessage" %)
240 (((
Aurelie Bertrand 120.1 241 ℹ This interface is only available to users with the **Dashboard > Manage form data** permission.
abertrand 41.2 242 )))
243
Aurelie Bertrand 120.1 244 == Configure an action ==
crandon 6.1 245
Aurelie Bertrand 109.2 246 (% class="wikigeneratedid" id="HActionavantenvoiduformulaire" %)
Aurelie Bertrand 120.1 247 The **Action **field **allows you **to configure an action to be carried out after the form has been submitted. This can be used, for example, to refresh the chart based on the form data and thus visualise the newly created data. See the page [[Refresh data streams after data entry>>doc:.form_refresh_flow.WebHome]] for more information.
Aurelie Bertrand 108.2 248
Aurelie Bertrand 120.1 249 = Advanced configuration =
Aurelie Bertrand 109.1 250
Aurelie Bertrand 120.1 251 == Configuring an action before form submission ==
Aurelie Bertrand 108.2 252
Aurelie Bertrand 120.1 253 It is possible to automatically perform certain actions on the information entered before a form is submitted by adding a JavaScript listener.
254 This allows you, in particular, to standardise the data (formatting, normalisation) or to manage custom business states, independently of the form’s native technical states.
abertrand 43.1 255
Aurelie Bertrand 120.1 256 Configuration is carried out in the JavaScript editor:
Aurelie Bertrand 108.2 257
Aurelie Bertrand 120.1 258 1. In the user menu, select **Settings** then **JavaScript Editor**.
259 1. Add the function “ddCtrl.addFormBeforeSubmitListener”, which will be triggered before the form data is submitted, in the following format:(((
Aurelie Bertrand 110.1 260 {{code cssClass="javascript" language="js"}}
261 ddCtrl.addFormBeforeSubmitListener(function(formId, formSubmission) {
262 // Logique de traitement
263 });
264 {{/code}}
265 )))
Aurelie Bertrand 93.1 266
Aurelie Bertrand 120.1 267 This function has two parameters:
Aurelie Bertrand 109.2 268
Aurelie Bertrand 120.1 269 * **formId**: the form ID
270 * **formSubmission**: the form data.
Aurelie Bertrand 109.2 271
Aurelie Bertrand 120.1 272 The **formSubmission **object **contains **several elements:
Aurelie Bertrand 109.2 273
Aurelie Bertrand 120.1 274 * **data**: the form data in key/value format, where the key is the field ID and the value is the value entered in the field.
275 * **metadata**: form metadata such as the form ID (formId), the page ID (pageId), the role ID (roleId), the portlet ID (portletId), etc.
276 * **state**: several possible values: “submitted” (data submitted), “draft” (submitted as a draft)
Aurelie Bertrand 109.2 277
Aurelie Bertrand 120.1 278 The action can be applied to the form data (“data” elements).
279 The “metadata” and “state” elements can be used in processing conditions.
Aurelie Bertrand 109.2 280
Aurelie Bertrand 120.1 281 To illustrate the function simply, in the example below, when the form with the ID “Patient” is submitted, the name entered in the “Name” field (key **f_name**) is automatically capitalised before submission.
Aurelie Bertrand 113.1 282
283 {{code language="js"}}
284 ddCtrl.addFormBeforeSubmitListener(function(formId, formSubmission)
285 {
286 if (formId == "Patient")
287 {
288 formSubmission.data.f_nom = formSubmission.data.f_nom.toUpperCase(); //Met en majuscule le champ f_nom du formulaire
289 }
290 });
291 {{/code}}
292
Aurelie Bertrand 120.1 293 === Example: managing custom states ===
Aurelie Bertrand 112.1 294
Aurelie Bertrand 120.1 295 Forms have two native technical states:
Aurelie Bertrand 112.2 296
Aurelie Bertrand 120.1 297 * **submitted**: allows a form to be submitted once all required fields have been completed;
298 * **draft**: allows the form to be saved as a draft, without full validation.
Aurelie Bertrand 112.2 299
Aurelie Bertrand 120.1 300 In certain contexts, it may be necessary to manage additional statuses, for example: closed or cancelled. In this case, we will use a custom status stored in the form data via a dedicated field (for example, Status). This status does not alter the technical behaviour of form submission but enables the management of the form’s business lifecycle.
Aurelie Bertrand 112.2 301
Aurelie Bertrand 120.1 302 Let’s take the example of a **“Registration”** form comprising:
Aurelie Bertrand 117.1 303
Aurelie Bertrand 120.1 304 * several fields (including at least one mandatory field),
305 * three buttons: **Submit**, **Draft** and **Close**,
306 * a **Status** field (f_statut) used to manage the different statuses, which can be hidden from the user.
Aurelie Bertrand 117.1 307
Aurelie Bertrand 116.1 308 [[image:1765896318888-638.png||height="429" width="476"]]
309
Aurelie Bertrand 120.1 310 To ensure the form is in the desired state depending on which button is clicked, we use the following JavaScript code:
Aurelie Bertrand 112.2 311
Aurelie Bertrand 113.1 312 (((
313 {{code language="javascript"}}
314 // Écouteur qui va se déclencher lors de l'envoi d'un formulaire
Aurelie Bertrand 112.1 315 ddCtrl.addFormBeforeSubmitListener(function(formId, formSubmission){
Aurelie Bertrand 113.1 316 // Ici on récupère l'identifiant du formulaire pour s'assurer de traiter celui voulu
Aurelie Bertrand 119.1 317 if (formId == "Inscription")
Aurelie Bertrand 109.2 318 {
Aurelie Bertrand 116.1 319 // On vérifie ici le type de bouton cliqué pour connaître l'état personnalisé que je souhaite traiter
Aurelie Bertrand 113.1 320 if (formSubmission.data["f_submit"] == true){ // Clic sur le bouton "Envoyer"
321 formSubmission.data["f_statut"] = "submit";
Aurelie Bertrand 118.1 322 formSubmission.state = "submitted";
Aurelie Bertrand 113.1 323 }
324 if (formSubmission.data["f_brouillon"] == true){ // Clic sur le bouton "Brouillon"
325 formSubmission.data["f_statut"] = "draft";
326 formSubmission.state = "draft";
327 }
328 if (formSubmission.data["f_fermer"] == true){ // Clic sur le bouton "Fermer"
329 formSubmission.data["f_statut"] = "closed";
330 }
Aurelie Bertrand 119.1 331 // On ajoute autant de bloc "if" qu'on a de statuts à gérer dans le formulaire
Aurelie Bertrand 109.2 332 }
333 });
334 {{/code}}
Aurelie Bertrand 113.1 335 )))
Aurelie Bertrand 109.2 336
Aurelie Bertrand 120.1 337 So, in this example:
Aurelie Bertrand 113.1 338
Aurelie Bertrand 120.1 339 * The “Submit” button sets the form to “submitted”.
340 * The “Draft” button allows you to save a partial version (draft) without validating all the required fields.
341 * The “Close” button simply marks the form as closed from a functional point of view, even if required fields have not been filled in.
Aurelie Bertrand 113.1 342
Aurelie Bertrand 120.1 343 == Configuring an email to be sent upon form submission{{id name="email"/}} ==
Aurelie Bertrand 109.2 344
Aurelie Bertrand 120.1 345 It is possible to configure the system to send an email when a form is submitted.
Aurelie Bertrand 93.1 346
Aurelie Bertrand 120.1 347 === Prerequisites ===
Aurelie Bertrand 93.1 348
Aurelie Bertrand 120.1 349 * The [[email server >>doc:Digdash.deployment.configuration.configuration_guide.email.WebHome]]must be configured.
350 * The user must have the //‘Dashboard -> Send an email’// permission.
Aurelie Bertrand 93.1 351
Aurelie Bertrand 93.2 352 === Configuration ===
Aurelie Bertrand 93.1 353
Aurelie Bertrand 120.1 354 Configuration is carried out in the JavaScript editor:
Aurelie Bertrand 93.2 355
Aurelie Bertrand 120.1 356 1. In the user menu, select **Settings** then **JavaScript Editor**.
357 1. Add the function “ddCtrl.addFormSubmitListener”, which will be triggered once the form has been submitted (after it has been sent to the server), in the following format:
Aurelie Bertrand 93.2 358
Aurelie Bertrand 93.3 359 {{code language="js"}}
Aurelie Bertrand 93.2 360 ddCtrl.addFormSubmitListener(function(formId, formSubmission)
361 {
362 if (formId == "Identifiant du formulaire")
363 {
Aurelie Bertrand 95.1 364 var message = "Contenu du message";
365 var res = ddCtrl.sendMail ("destinataires (séparés par des virgules)", "sujet du mail", message);
Aurelie Bertrand 93.2 366 }
367 });
368 {{/code}}
369
Aurelie Bertrand 120.1 370 The message can contain the values of the fields entered by the user via the “formSubmission.data” object in the following format~://formSubmission.data.f_field_name.//
Aurelie Bertrand 93.2 371
Aurelie Bertrand 120.1 372 **Example**
Aurelie Bertrand 93.2 373
Aurelie Bertrand 120.1 374 We have a survey form with the ID **‘Survey** ’ containing the fields **‘User** ’ and **‘Tool**’. We wish to send an email to recipients with the information entered for these fields in the message body.
Aurelie Bertrand 96.1 375
Aurelie Bertrand 95.1 376 {{code language="js"}}
Aurelie Bertrand 93.3 377 ddCtrl.addFormSubmitListener(function(formId, formSubmission)
378 {
379 if (formId == "Sondage")
380 {
381 var message = "L'utilisateur '" + formSubmission.data.f_utilisateur + "' a répondu '" + formSubmission.data.f_outil + "' au sondage Outil préféré.";
382 var res = ddCtrl.sendMail("jean.dupont@mail.com,jean.dupond@mail.com", "Sondage", message);
383 }
384 });
385 {{/code}}
386
Aurelie Bertrand 120.1 387 Upon submission of the form, with //‘Jean’// entered in the **‘User’ **field **and **//‘DigDash’// in the **‘Tool’** field//, the //recipients will receive an email with the subject line **‘Survey’** and the following message~://**The user ‘Jean’ answered ‘DigDash’ in the ‘Favourite BI Tool’ survey**.//
Aurelie Bertrand 94.1 388
Aurelie Bertrand 120.1 389 = Using a form =
crandon 6.1 390
Aurelie Bertrand 120.1 391 Once the ‘Form’ object has been added and configured on the dashboard page, and the page has been saved, the form becomes accessible to users who have access to this page and who have the **‘Dashboard > Add data via a form’** permission.
crandon 6.1 392
Aurelie Bertrand 120.1 393 Once the user has entered the data, it is automatically saved to the database. If a data source refresh is configured, the new data is imported into DigDash and will therefore be available on the dashboard.
crandon 6.1 394
Aurelie Bertrand 120.1 395 It is also possible to display the form as a pop-up, using the `openFormInWindow` function, which can be configured at chart level; details of this function are available in the documentation [[JavaScript functions>>doc:Digdash.customization.customization_DDE.customization_api.WebHome]].
crandon 8.1 396
Aurelie Bertrand 120.1 397 = Using data from a form =
crandon 12.1 398
Aurelie Bertrand 120.1 399 Once the form has been created, the data table is created in the database, so this data can be utilised by DigDash.
crandon 12.1 400
Aurelie Bertrand 120.1 401 To do this, simply use Studio to create a data model based on the newly created SQL table by selecting the database chosen to store the form data. As a reminder, the table name is the form ID entered by the user.
crandon 12.1 402
Aurelie Bertrand 120.1 403 If the table is stored in our embedded H2 database, here are the login credentials required to access it:
crandon 12.1 404
405 {{code language="text"}}
406 url : jdbc:h2:file:[répertoire de configuration de DigDash]\Enterprise Server\ddenterpriseapi\config\DDDataEntry;AUTO_SERVER=TRUE
407 identifiants : sa/sa
408 {{/code}}
409
Aurelie Bertrand 120.1 410 Once the data model has been created, you can then generate charts from it.
abertrand 19.2 411
Aurelie Bertrand 120.1 412 = Security =
abertrand 19.2 413
Aurelie Bertrand 66.1 414 (% class="box warningmessage" %)
415 (((
Aurelie Bertrand 120.1 416 ❗**Invalid JSON Logic code**
417 \\Invalid JSON**code** (conditions never checked, typographical errors, etc.) makes it impossible to access the form.
418 The **‘Admin -> Manage all forms’** permission allows you to view the form and correct this issue. See the page [[Permissions (ACL)>>doc:Digdash.deployment.configuration.administration.User_management.Authorization_management.acls.WebHome]] for further details.
Aurelie Bertrand 66.1 419 )))
420
Aurelie Bertrand 120.1 421 == Securing a form{{id name="Sécurité_form"/}} ==
abertrand 24.1 422
Aurelie Bertrand 120.1 423 To secure a form, you can associate it with a role. Only users with the defined role will be able to access the form. To do this, select the role to which the form is associated from the **Role** drop-down list.
424 If you wish to make the form visible to all roles, select **None**.
abertrand 25.2 425
Aurelie Bertrand 120.1 426 It is also possible to restrict access to a form based on a user profile or via custom sharing. To do this, select one of the options from the **Sharing** drop-down list:
abertrand 46.2 427
abertrand 50.1 428 (% class="box infomessage" %)
429 (((
Aurelie Bertrand 120.1 430 If a **Role is **selected, only users with that role will have access.
abertrand 50.1 431 )))
abertrand 46.3 432
Aurelie Bertrand 120.1 433 * **All: **all users will have access to the form.
434 * **//User profile//**: if user profiles are available, you can select a user profile to restrict access to the form to. Only users with that user profile will have access to the form.
435 * **Custom**: you can define a custom sharing setting using JSON Logic. To do this, click the [[image:1709631321085-490.png||queryString="width=17&height=18" height="18" width="17"]] and enter the required JSON Logic in the **Custom Sharing** interface. For example, to restrict access to the form to users with the user profile ‘profile_A’ or ‘profile_B’, use:
Aurelie Bertrand 84.1 436 [[image:Data_entry_custom_share_FR.png||alt="Partage personnalisé"]]
abertrand 46.3 437
Aurelie Bertrand 120.1 438 When a user does not have access to a form:
abertrand 50.1 439
Aurelie Bertrand 120.1 440 * the form no longer appears in the **Forms **list **in **the dashboard editor.
441 * if the form is added to a dashboard page, an error is displayed:
abertrand 50.2 442 [[image:Erreur_formulaire.png||queryString="width=563&height=315" alt="Erreur formulaire" height="315" width="563"]]
abertrand 50.1 443
Aurelie Bertrand 120.1 444 == Securing a form field{{id name="Sécurité_champ_form"/}} ==
abertrand 25.2 445
Aurelie Bertrand 120.1 446 === Based on a user profile or a user setting ===
abertrand 25.2 447
abertrand 55.2 448 (% class="wikigeneratedid" %)
Aurelie Bertrand 120.1 449 {{id name="Sécurité_champ_form"/}}It is possible to restrict access to a form field based on a user profile or a user setting.
abertrand 55.2 450
Aurelie Bertrand 120.1 451 To do this, configure a logic rule in the **Logic** tab of the component’s edit window.
abertrand 25.2 452
Aurelie Bertrand 120.1 453 To check whether the user has the specified profile, a profile can be used in the form ${user.profile.profilename} in the JSON Logic. This keyword returns a value of “true” or “false”.
454 To check the parameter of the logged-in user, a user parameter can be used in the form ${user.myparam} in the JSON Logic.
abertrand 28.1 455
Aurelie Bertrand 120.1 456 1. Enter the **Name of the logic**.
457 1. In the **Trigger** section, select the **JSON Logic** type.
458 1. Enter the JSON Logic code. For example:
abertrand 25.2 459
abertrand 44.1 460 {{code language="shell"}}
461 {
462 "==": [
463 "${user.profile.profil_A}",
464 "true"
465 ]
466 }
467 {{/code}}
abertrand 28.1 468
Aurelie Bertrand 120.1 469 In this example, the trigger is activated if the user has the //profil_A //profile //.//
abertrand 25.2 470
abertrand 28.1 471 (% start="4" %)
Aurelie Bertrand 120.1 472 1. Then define the action to be performed when the trigger is activated.
473 In this example, if the trigger is activated, the “//Disabled//” property is set to “//True//”. The form field is then read-only.
abertrand 29.1 474 [[image:Exemple_action.png||queryString="width=493&height=477" alt="Exemple_action" height="477" width="493"]]
Aurelie Bertrand 120.1 475 1. Click **Save action and then Save logic.**
abertrand 25.2 476
Aurelie Bertrand 120.1 477 === Depending on the data ===
abertrand 55.3 478
Aurelie Bertrand 120.1 479 It is possible to secure a form field based on the value of a dimension or measure retrieved from a data stream (chart) or a data model.
abertrand 55.3 480
Aurelie Bertrand 120.1 481 To do this, follow the same procedure as in the previous section, but use JSON Logic code that references the stream or data model ID, filters, and a dimension or measure to define the trigger.
abertrand 55.3 482
Aurelie Bertrand 120.1 483 **Example of JSON Logic based on a flow (chart):**
abertrand 55.4 484
abertrand 56.1 485 {{code language="JSON"}}
486 {
487 "==":
488 [
489 "${cube.value({\"flowId\":\"b312f6be\",\"filters\":[{\"dim\": \"Matériel\", \"member\":\"Samsung Galaxy\"}],\"res\":\"Type de ligne\"})}",
490 "Mobile"
491 ]
492 }
493 {{/code}}
abertrand 55.5 494
Aurelie Bertrand 120.1 495 where:
abertrand 55.5 496
Aurelie Bertrand 120.1 497 * **flowId**: the identifier of the flow from which the desired data will be retrieved.
498 * **filters**: filters to be applied to the chart so that only one row of data is returned by the server.
499 * **res**: the dimension or measure of the value to be retrieved.
abertrand 56.1 500
Aurelie Bertrand 120.1 501 If the value returned by //"${cube.value({\"flowId\":\"b312f6be\",\"filters\":[{\"dim\": \"Hardware\", \"member\":\"Samsung Galaxy\"}],\"res\":\"Line type\"})}" is //equal to the desired value //"Mobile", then //the action is triggered.
abertrand 56.1 502
Aurelie Bertrand 59.1 503 (% class="box infomessage" %)
504 (((
Aurelie Bertrand 120.1 505 ℹ Backslashes "\" are used in the JSON code to escape double quotation marks " so that they are not interpreted as the end of a string. This ensures that the JSON code retains its correct structure and is interpreted correctly by the system without errors.
Aurelie Bertrand 59.1 506 )))
507
Aurelie Bertrand 120.1 508 **Example of JSON Logic based on a data model:**
abertrand 56.1 509
510 {{code language="JSON"}}
511 {
512 "==":
513 [
514 "${cube.value({\"dmId\":\"0b2583609f86d37754ce2ada372f31ae\",\"filters\":[{\"dim\": \"Matériel\", \"member\":\"Samsung Galaxy\"}],\"res\":\"Type de ligne\"})}",
515 "Mobile"
516 ]
517 }
518 {{/code}}
519
Aurelie Bertrand 120.1 520 where:
abertrand 56.1 521
Aurelie Bertrand 120.1 522 * **dmId**: identifier of the data model from which the desired data will be retrieved.
523 * **filters**: filters to be applied to the data model so that only one row of data is returned by the server.
524 * **res**: the dimension or measure of the value to be retrieved.
abertrand 56.1 525
Aurelie Bertrand 120.1 526 If the value returned by //"${cube.value({\"dmId\":\"0b2583609f86d37754ce2ada372f31ae\",\"filters\":[{\"dim\": \"Hardware\", \"member\":\"Samsung Galaxy\"}],\"res\":\"Row type\"})}" is //equal to the desired value //"Mobile", then //the action is triggered.