Question T10248
Visible to All Users

How to get question TITLE, not NAME?

created 3 years ago

Hi!

I need to force my surveys to have TITLE fields defined for all questions.
I know that if TITLE is not defined than NAME is used, but in my code i need to check (and retrieve it) if TITLE is defined despite the presence of NAME.
How can i achieve that?

JavaScript
this.creator.getAllQuestions().forEach(e=>{ /* * I've tried: * - e.title * - e.getPropertyValue('title) * - e.getPropertyByName('title') * - e.hasTitle <-- checks NAME, not TITLE * - e.fullTitle * etc... * Apparently all of them check the NAME property */ if(!e.title) //<-- check if TITLE field is filled { e.title = customFunctionToFormat(e.name) // <-- set TITLE with a formated NAME } })

Thanks!

Answers approved by surveyjs Support

created 3 years ago

Hello Theo,
Please use the following code:

JavaScript
question.locTitle.isEmpty

Thank you,
Andrew
SurveyJS Team

    Comments (2)

      That worked, thanks!

        You are welcome!

        Andrew
        SurveyJS Team
        If you like our products, please take a moment to share your experience with our company by contributing a short review for SurveyJS page at g2.com or at Trustpilot.com.
        As we’re building our business, every review helps build credibility for future customers and your feedback would be greatly appreciated.