Add note to instance_name

i have a note with name ‘note1’ and label “2022 supervisors list”
Q1, Name of facility with Options: ZAA, GAXU, MOX
how do i use concat so that when ZAA submits their data, the form will be named as ‘ZAA 2022 supervisors list’
is used this formular “concat(${Q1}, ‘-’, ${note1})” in the instance_name but the “2022 supervisors list” is not showing

Hello @yendor,
Just a quick reply. A ${ } variable reference will never give you a label, but the (entered) value.

I am afraid there is no simple function to get the label of a question (variable); different to jr:choice_name(…). But @Kal_Lam or @Xiphware might know more, please. Maybe itext() or a path/attribute reference could help here?

A workaround could be

  • to change your note to text type with read_only. Then you could reference the text var value.
  • or to calculate the note text in a calculate type which can be referenced in the instance_name.
1 Like

@yendor, maybe another approach would be to use 2022 supervisors list directly to your concat expression as a default text.

1 Like

okay thanks

1 Like

Minor correction: “I am afraid there is no simple function to get the label of a question…”

:slight_smile:

Basically, there is no way at runtime - within your form - to programmatically get the label that would be displayed for an arbitrary XForm question. So you need to hardcode something in your form to do it instead, ala…

1 Like

Based on your description, it seems like you want to concatenate the selected option from question Q1 with the label “2022 supervisors list” to create the form name. It looks like you are using the correct formula, but there might be an issue with how you are implementing it. Let’s break down the formula and make sure it’s correctly used:

The formula you mentioned is: concat(${Q1}, '-', ${note1})

Let’s assume:

  • ${Q1} represents the selected option from the question with the options ZAA, GAXU, and MOX.
  • ${note1} represents the label “2022 supervisors list”.

If ZAA is selected for Q1, the formula should produce the string: “ZAA - 2022 supervisors list”.

To use the formula correctly in the instance_name, you need to ensure the syntax is correct, and the variables are properly referenced.

Here’s an example of how you can use the formula in the instance_name property of your form:

xmlCopy code

<!-- Assuming this is an XForm or XLSForm -->
<instance>
  <data id="supervisors_data">
    <meta>
      <instanceID/> <!-- This will be automatically populated -->
    </meta>
    <form_name/>
  </data>
</instance>

<bind nodeset="form_name" calculate="concat(${Q1}, ' 2022 supervisors list')"/>

<!-- Your survey form questions here, including question Q1 and note1 -->

In this example, we create a data node called form_name, and the calculate attribute is set to the concatenation formula. When the user selects an option from question Q1, the form_name will be automatically populated with the concatenated result.

Please ensure that the variables ${Q1} and ${note1} are correctly referenced in your actual implementation, and the syntax of the form is correct. If the “2022 supervisors list” is still not showing up, double-check the variable names and the overall form structure to troubleshoot any potential issues.