Question T18472
Visible to All Users

Setting a default value for custom ItemValue property based on custom question property

created 7 months ago

Is it possible to set a default value on the itemValue "Color" property based to the value of the question "NewItemsColor" property when adding new choices?

Plunkr: https://plnkr.co/edit/VbOJYB6JpMnCPD8B

Answers approved by surveyjs Support

created 7 months ago

Hello Giorgio,
To copy a question's color property value to a newly added choice's color property, implement the creator.onItemValueAdded event and copy the question's property value to a corresponding property of a newly added choice item.

JavaScript
creator.onItemValueAdded.add((sender, options) => { if(!!options.obj.NewItemsColor){ options.newItem.Color = options.obj.NewItemsColor; } });

View Demo

And before I let you go…If you have free time, I would appreciate it if you could leave a short review on SurveyJS page at Capterra. As we’re building our business, every review helps build credibility for future customers and your feedback would be greatly appreciated.

Thank you in advance!

    Comments (2)

      Perfect, it works. I have already reviewed the product.
      Thank you!

        Thank you.

        Please feel free to contact us at any time.