Displaying data from a previously submitted form

Hello @diana @samuel

Is it possible to display data from a previously submitted form as a label in the new task form being filled out as a follow up for example if i feel out a check box field in form A and submit it, and i want to display some of the results in that submitted form as a label in the next follow up task form B

Yes this should be possible. You can read some more details in the task documentation, but I think the basic workflow would look like this:

  • In your task definition (for the task triggered by submitting form A) you would want to set your desired value from form A to the content for the newly triggered form B using the modifyContent function:

    modifyContent: function (content, contact, report, event) {
      content.my_field = getField(report, 'my_field');
    }
    
  • Then in form B, you would need to define a hidden field named my_field within the inputs group. When this form is triggered by a task, this field will be automatically populated with data from the task.

  • Finally, your label in form B just needs to reference the hidden field in the label text: My field: ${my_field}

You can find more examples of using the modifyContent functionality in the sample config here: cht-core/config at master · medic/cht-core · GitHub

1 Like