Wiki source code of Saisie de données
Last modified by Aurelie Bertrand on 2026/06/26 15:03
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{ddtoc/}} | ||
| 2 | |||
| 3 | ---- | ||
| 4 | |||
| 5 | = Preamble = | ||
| 6 | |||
| 7 | The purpose of data entry is to add new data via a form displayed on the dashboard. | ||
| 8 | |||
| 9 | The principle involves creating a form that automatically generates a table in a relational database such as MySQL, PostgreSQL, MariaDB, H2 or Oracle. | ||
| 10 | |||
| 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. | ||
| 12 | |||
| 13 | = Configuring data entry = | ||
| 14 | |||
| 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]] | ||
| 16 | |||
| 17 | This interface allows you to enable the feature and select the database in which the data entered will be stored. | ||
| 18 | |||
| 19 | [[image:Data_entry_configuration_FR.png||alt="Configuration saisie données"]] | ||
| 20 | |||
| 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. | ||
| 22 | |||
| 23 | (% class="box warningmessage" %) | ||
| 24 | ((( | ||
| 25 | ⚠ Only MySQL, PostgreSQL, MariaDB, H2 and Oracle databases are supported. | ||
| 26 | ))) | ||
| 27 | |||
| 28 | = Create a form = | ||
| 29 | |||
| 30 | (% class="box infomessage" %) | ||
| 31 | ((( | ||
| 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]]. | ||
| 33 | ))) | ||
| 34 | |||
| 35 | Once the feature has been enabled and configured, you can create one or more forms. | ||
| 36 | |||
| 37 | To do this: | ||
| 38 | |||
| 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. | ||
| 40 | [[image:Data_entry_new_form_FR.png||alt="Nouveau formulaire"]] | ||
| 41 | 1. Then click the **New form** button. | ||
| 42 | ➡ The form creation interface will then appear. | ||
| 43 | |||
| 44 | (% class="box infomessage" %) | ||
| 45 | ((( | ||
| 46 | ℹ This interface is only available to users with the**Dashboard > Create a form** permission. | ||
| 47 | To save the form, the user must have: | ||
| 48 | |||
| 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. | ||
| 51 | ))) | ||
| 52 | |||
| 53 | Here is the form creation interface: | ||
| 54 | |||
| 55 | [[image:Data_entry_new_form_page_FR.png]] | ||
| 56 | |||
| 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. | ||
| 63 | |||
| 64 | (% class="box infomessage" %) | ||
| 65 | ((( | ||
| 66 | ℹ A form must contain **at least one field and a button** to submit the data. | ||
| 67 | ))) | ||
| 68 | |||
| 69 | [[image:Data_entry_form_example_FR.png]] | ||
| 70 | |||
| 71 | (% start="5" %) | ||
| 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. | ||
| 74 | |||
| 75 | You can edit, move, copy or delete a component using the toolbar that appears when you hover over the component with the mouse. | ||
| 76 | [[image:Editer_composant.png||alt="Edition_composant"]] | ||
| 77 | |||
| 78 | |||
| 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). | ||
| 80 | |||
| 81 | This table will contain all the fields present in the form, as well as the following columns: | ||
| 82 | |||
| 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 | ||
| 87 | |||
| 88 | Deleting a form will result in the deletion of the table and the data it contains. | ||
| 89 | |||
| 90 | == Configuring form fields{{id name="Configuration_champ_form"/}} == | ||
| 91 | |||
| 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. | ||
| 93 | |||
| 94 | (% class="box infomessage" %) | ||
| 95 | ((( | ||
| 96 | 💡 You can get help on the current component by clicking the **Help **button **in the **top right-hand corner of the configuration window. | ||
| 97 | ))) | ||
| 98 | |||
| 99 | The**Preview** section on the right allows you to preview how the form will look and to save the field’s configuration. | ||
| 100 | |||
| 101 | [[image:Boite_composant.png||alt="Composant"]] | ||
| 102 | |||
| 103 | (% class="box infomessage" %) | ||
| 104 | ((( | ||
| 105 | ℹ The tabs, as well as the fields and options available for each one, differ depending on the component type. | ||
| 106 | ))) | ||
| 107 | |||
| 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. | ||
| 123 | |||
| 124 | === Configuring a ‘Save as Draft’ button{{id name="Brouillon"/}} === | ||
| 125 | |||
| 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: | ||
| 127 | |||
| 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’.// | ||
| 133 | [[image:Composant_bouton_brouillon.png||alt="Bouton_brouillon"]] | ||
| 134 | 1. Configure the other fields/options as required. | ||
| 135 | 1. Click **Save** to confirm the Button component’s configuration. | ||
| 136 | |||
| 137 | === Configuring a drop-down list based on the number of items{{id name="Liste"/}} === | ||
| 138 | |||
| 139 | When a drop-down list is linked to a dimension, the configuration varies depending on the number of members in the dimension. | ||
| 140 | |||
| 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. | ||
| 146 | [[image:Widget_choiceJS.png||queryString="width=399&height=207" alt="Liste_choicesJS" height="207" width="399"]] | ||
| 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. | ||
| 148 | [[image:Widget_HTML5.png||queryString="width=427&height=99" alt="Liste_HTML5" height="99" width="427"]] | ||
| 149 | |||
| 150 | (% class="box infomessage" %) | ||
| 151 | ((( | ||
| 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**. | ||
| 153 | ))) | ||
| 154 | |||
| 155 | (% start="4" %) | ||
| 156 | 1. Configure the other fields/options as required. | ||
| 157 | 1. Click **Save** to confirm the configuration of the Drop-down List component. | ||
| 158 | |||
| 159 | === Configuring conditional display based on multiple values === | ||
| 160 | |||
| 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: | ||
| 163 | |||
| 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: | ||
| 170 | |||
| 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" %) | ||
| 196 | We then add the action to be performed when the condition defined below is met: | ||
| 197 | |||
| 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: | ||
| 202 | [[image:Condition_example_action_FR.png||alt="Action"]] | ||
| 203 | 1. Click the **Save action**button, then **Save logic**. | ||
| 204 | 1. Finally, save the field. | ||
| 205 | |||
| 206 | == Edit / Delete a form == | ||
| 207 | |||
| 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**. | ||
| 209 | |||
| 210 | [[image:Data_entry_form_menu_FR.png||alt="Editer/Supprimer formulaire"]] | ||
| 211 | |||
| 212 | = Add a form to the dashboard = | ||
| 213 | |||
| 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. | ||
| 215 | |||
| 216 | Form objects are configured via the **Settings -> Properties** menu. | ||
| 217 | |||
| 218 | == Linking a field to data == | ||
| 219 | |||
| 220 | It is possible to link a form field to data present on the dashboard. Two types of link are possible: | ||
| 221 | |||
| 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. | ||
| 224 | |||
| 225 | To do this: | ||
| 226 | |||
| 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**. | ||
| 231 | [[image:Data_entry_link_FR.png||alt="Lien"]] | ||
| 232 | |||
| 233 | == View a preview of the data == | ||
| 234 | |||
| 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. | ||
| 236 | |||
| 237 | [[image:Aperçu_données.png||queryString="width=735&height=249" alt="Aperçu_données" height="249" width="735"]] | ||
| 238 | |||
| 239 | (% class="box infomessage" %) | ||
| 240 | ((( | ||
| 241 | ℹ This interface is only available to users with the **Dashboard > Manage form data** permission. | ||
| 242 | ))) | ||
| 243 | |||
| 244 | == Configure an action == | ||
| 245 | |||
| 246 | (% class="wikigeneratedid" id="HActionavantenvoiduformulaire" %) | ||
| 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. | ||
| 248 | |||
| 249 | = Advanced configuration = | ||
| 250 | |||
| 251 | == Configuring an action before form submission == | ||
| 252 | |||
| 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. | ||
| 255 | |||
| 256 | Configuration is carried out in the JavaScript editor: | ||
| 257 | |||
| 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:((( | ||
| 260 | {{code cssClass="javascript" language="js"}} | ||
| 261 | ddCtrl.addFormBeforeSubmitListener(function(formId, formSubmission) { | ||
| 262 | // Logique de traitement | ||
| 263 | }); | ||
| 264 | {{/code}} | ||
| 265 | ))) | ||
| 266 | |||
| 267 | This function has two parameters: | ||
| 268 | |||
| 269 | * **formId**: the form ID | ||
| 270 | * **formSubmission**: the form data. | ||
| 271 | |||
| 272 | The **formSubmission **object **contains **several elements: | ||
| 273 | |||
| 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) | ||
| 277 | |||
| 278 | The action can be applied to the form data (“data” elements). | ||
| 279 | The “metadata” and “state” elements can be used in processing conditions. | ||
| 280 | |||
| 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. | ||
| 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 | |||
| 293 | === Example: managing custom states === | ||
| 294 | |||
| 295 | Forms have two native technical states: | ||
| 296 | |||
| 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. | ||
| 299 | |||
| 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. | ||
| 301 | |||
| 302 | Let’s take the example of a **“Registration”** form comprising: | ||
| 303 | |||
| 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. | ||
| 307 | |||
| 308 | [[image:1765896318888-638.png||height="429" width="476"]] | ||
| 309 | |||
| 310 | To ensure the form is in the desired state depending on which button is clicked, we use the following JavaScript code: | ||
| 311 | |||
| 312 | ((( | ||
| 313 | {{code language="javascript"}} | ||
| 314 | // Écouteur qui va se déclencher lors de l'envoi d'un formulaire | ||
| 315 | ddCtrl.addFormBeforeSubmitListener(function(formId, formSubmission){ | ||
| 316 | // Ici on récupère l'identifiant du formulaire pour s'assurer de traiter celui voulu | ||
| 317 | if (formId == "Inscription") | ||
| 318 | { | ||
| 319 | // On vérifie ici le type de bouton cliqué pour connaître l'état personnalisé que je souhaite traiter | ||
| 320 | if (formSubmission.data["f_submit"] == true){ // Clic sur le bouton "Envoyer" | ||
| 321 | formSubmission.data["f_statut"] = "submit"; | ||
| 322 | formSubmission.state = "submitted"; | ||
| 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 | } | ||
| 331 | // On ajoute autant de bloc "if" qu'on a de statuts à gérer dans le formulaire | ||
| 332 | } | ||
| 333 | }); | ||
| 334 | {{/code}} | ||
| 335 | ))) | ||
| 336 | |||
| 337 | So, in this example: | ||
| 338 | |||
| 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. | ||
| 342 | |||
| 343 | == Configuring an email to be sent upon form submission{{id name="email"/}} == | ||
| 344 | |||
| 345 | It is possible to configure the system to send an email when a form is submitted. | ||
| 346 | |||
| 347 | === Prerequisites === | ||
| 348 | |||
| 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. | ||
| 351 | |||
| 352 | === Configuration === | ||
| 353 | |||
| 354 | Configuration is carried out in the JavaScript editor: | ||
| 355 | |||
| 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: | ||
| 358 | |||
| 359 | {{code language="js"}} | ||
| 360 | ddCtrl.addFormSubmitListener(function(formId, formSubmission) | ||
| 361 | { | ||
| 362 | if (formId == "Identifiant du formulaire") | ||
| 363 | { | ||
| 364 | var message = "Contenu du message"; | ||
| 365 | var res = ddCtrl.sendMail ("destinataires (séparés par des virgules)", "sujet du mail", message); | ||
| 366 | } | ||
| 367 | }); | ||
| 368 | {{/code}} | ||
| 369 | |||
| 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.// | ||
| 371 | |||
| 372 | **Example** | ||
| 373 | |||
| 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. | ||
| 375 | |||
| 376 | {{code language="js"}} | ||
| 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 | |||
| 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**.// | ||
| 388 | |||
| 389 | = Using a form = | ||
| 390 | |||
| 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. | ||
| 392 | |||
| 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. | ||
| 394 | |||
| 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]]. | ||
| 396 | |||
| 397 | = Using data from a form = | ||
| 398 | |||
| 399 | Once the form has been created, the data table is created in the database, so this data can be utilised by DigDash. | ||
| 400 | |||
| 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. | ||
| 402 | |||
| 403 | If the table is stored in our embedded H2 database, here are the login credentials required to access it: | ||
| 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 | |||
| 410 | Once the data model has been created, you can then generate charts from it. | ||
| 411 | |||
| 412 | = Security = | ||
| 413 | |||
| 414 | (% class="box warningmessage" %) | ||
| 415 | ((( | ||
| 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. | ||
| 419 | ))) | ||
| 420 | |||
| 421 | == Securing a form{{id name="Sécurité_form"/}} == | ||
| 422 | |||
| 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**. | ||
| 425 | |||
| 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: | ||
| 427 | |||
| 428 | (% class="box infomessage" %) | ||
| 429 | ((( | ||
| 430 | If a **Role is **selected, only users with that role will have access. | ||
| 431 | ))) | ||
| 432 | |||
| 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: | ||
| 436 | [[image:Data_entry_custom_share_FR.png||alt="Partage personnalisé"]] | ||
| 437 | |||
| 438 | When a user does not have access to a form: | ||
| 439 | |||
| 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: | ||
| 442 | [[image:Erreur_formulaire.png||queryString="width=563&height=315" alt="Erreur formulaire" height="315" width="563"]] | ||
| 443 | |||
| 444 | == Securing a form field{{id name="Sécurité_champ_form"/}} == | ||
| 445 | |||
| 446 | === Based on a user profile or a user setting === | ||
| 447 | |||
| 448 | (% class="wikigeneratedid" %) | ||
| 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. | ||
| 450 | |||
| 451 | To do this, configure a logic rule in the **Logic** tab of the component’s edit window. | ||
| 452 | |||
| 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. | ||
| 455 | |||
| 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: | ||
| 459 | |||
| 460 | {{code language="shell"}} | ||
| 461 | { | ||
| 462 | "==": [ | ||
| 463 | "${user.profile.profil_A}", | ||
| 464 | "true" | ||
| 465 | ] | ||
| 466 | } | ||
| 467 | {{/code}} | ||
| 468 | |||
| 469 | In this example, the trigger is activated if the user has the //profil_A //profile //.// | ||
| 470 | |||
| 471 | (% start="4" %) | ||
| 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. | ||
| 474 | [[image:Exemple_action.png||queryString="width=493&height=477" alt="Exemple_action" height="477" width="493"]] | ||
| 475 | 1. Click **Save action and then Save logic.** | ||
| 476 | |||
| 477 | === Depending on the data === | ||
| 478 | |||
| 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. | ||
| 480 | |||
| 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. | ||
| 482 | |||
| 483 | **Example of JSON Logic based on a flow (chart):** | ||
| 484 | |||
| 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}} | ||
| 494 | |||
| 495 | where: | ||
| 496 | |||
| 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. | ||
| 500 | |||
| 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. | ||
| 502 | |||
| 503 | (% class="box infomessage" %) | ||
| 504 | ((( | ||
| 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. | ||
| 506 | ))) | ||
| 507 | |||
| 508 | **Example of JSON Logic based on a data model:** | ||
| 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 | |||
| 520 | where: | ||
| 521 | |||
| 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. | ||
| 525 | |||
| 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. |