Calculation in custom forms only works in preview

56 views
Skip to first unread message

Laura

unread,
May 31, 2023, 9:48:31 AM5/31/23
to xnat_discussion
Hey,
I created some custom forms in which some calculation is done. My problem is, that this only works in the preview. When I save my settings and run the form, the field, where the result of the calculation should be displayed remains empty.
For example I wanna add two values of two number fields. The result should be displayed in a further field. All three field are in one panel. (Details below)

Do you habe an idea to solve this issue?

Laura
------------------------------
XNAT version: 1.8.8
Custom form.png
Preview.png

And the .json code of the panel:
{
  "title": "Addition",
  "theme": "warning",
  "collapsible": false,
  "key": "addition",
  "type": "panel",
  "label": "Panel",
  "input": false,
  "tableView": false,
  "components": [
    {
      "key": "number1",
      "type": "xnatNumber",
      "input": true,
      "label": "Number 1",
      "delimiter": false,
      "tableView": false,
      "requireDecimal": false,
      "truncateMultipleSpaces": false
    },
    {
      "key": "number2",
      "type": "xnatNumber",
      "input": true,
      "label": "Number 2",
      "delimiter": false,
      "tableView": false,
      "requireDecimal": false,
      "truncateMultipleSpaces": false
    },
    {
      "label": "Result (Textfield)",
      "redrawOn": "data",
      "calculateValue": {
        "+": [
          {
            "var": "data.number1"
          },
          {
            "var": "data.number2"
          }
        ]
      },
      "key": "result",
      "type": "textfield",
      "input": true,
      "prefix": "=",
      "disabled": true,
      "refreshOn": "change",
      "tableView": true,
      "keyModified": true
    }
  ]
}

Ian Gauthier

unread,
May 31, 2023, 3:58:45 PM5/31/23
to xnat_discussion
Hi Laura,

Unfortunately, calculated value type fields are not currently supported within the current version of XNAT custom forms. As such, this is the expected functionality for these inputs. We are planning to add this type of field into XNAT in a future version of custom forms and we have noted down your interest in them within our ticketing system.

Thanks for reaching out,
Ian

roman....@gmail.com

unread,
Feb 26, 2024, 10:07:04 AMFeb 26
to xnat_discussion
Hi Ian, 

I would like to ask you if there is any current development in this matter. Laura used to work in our group and helped us setting up xnat and custom forms.  

Sincerely 
Sandro
Reply all
Reply to author
Forward
0 new messages