Question T15366
Visible to All Users

Use custom function expression in the JSON

created a year ago

Hi, is it possible to add custom function and use it in the JSON. There are custom functions for expressions but is it possible to use them in other properties e.g. title, description, etc?

Clipboard-File-1.png
Clipboard-File-2.png

Answers approved by surveyjs Support

created a year ago

Hello Marian,
It is possible to use functions in properties of the expression/condition type. Unfortunately, titles and descriptions cannot directly embed functions. However, they can accept placeholders which represent other question or calculated field values. If you wish to use a function in a question's title, you can create a calculated field, include your custom question into its expression and use the calculated field in a question title. Consider this example:

JSON
{ "logoPosition": "right", "pages": [ { "name": "page1", "elements": [ { "type": "text", "name": "question1", "title": "Month: {cfMonth}" } ] } ], "calculatedValues": [ { "name": "cfMonth", "expression": "month(today())" } ] }

Please let me know if you have any further questions.

    Comments (2)
    MT MT
    Marian Turchyn a year ago

      It seems like calculatedValues are calculated only once, and not dynamic. And also I would like to pass params to it like {question1}.

        Hello,
        Have you considered using an Expression question type instead?