Dear support,
I have encountered a problem, that I do not know how to solve. We have a solution, where we create Questionnaires using Survey Creator, populate the input and display the result for people to fill in. The situation is that when I use the Survey Creator and add the value "currentDate()" in defaultValueExpression field, it displays everything correctly - the field is automatically filled with the current date. BUT when I open the same Survey in Viewer, the values are not filled in.
Used Libraries:
"survey-react": "^1.9.6",
"survey-core": "^1.9.6",
"survey-creator-react": "^1.9.6-beta.1"
Unfortunately updating the libraries to latest version did not solve the problem.
Example JSON of the Survey:
{
"logoPosition": "right",
"pages": [
{
"name": "Page1",
"elements": [
{
"type": "text",
"name": "Frage2",
"title": "Ausfülldatum",
"defaultValueExpression": "currentDate()"
}
]
}
]
}
The value of "defaultValueExpression": "currentDate()" exists in all states of the Survey, but when displaying it, it does not execute and the field stays empty. I'm guessing there is a mistake on the way how we render the Component:
Code//imports
export default class Questionnaire extends Component {
constructor(props, context) {
super(props);
Survey.Survey.cssType = "bootstrap";
Survey.defaultBootstrapCss.navigationButton = "btn btn-primary success";
Survey.showNavigationButtons = false;
const germanLocalization = Survey.surveyLocalization.locales.de;
germanLocalization.addPanel = "Hinzufügen";
germanLocalization.noEntriesText = "Es sind noch keine Einträge vorhanden.\nKlicken Sie auf den Button um einen neuen Eintrag hinzuzufügen.";
germanLocalization.fileDragAreaPlaceholder = "Ziehen Sie eine Datei hierher oder klicken Sie auf den Button um eine Datei auszuwählen.";
Survey.StylesManager.applyTheme("defaultV2");
this.state = {
surveyIsSaved: false,
};
}
// some other code
render() {
return (
<Survey.Survey
json={this.props.surveyJson}
onAfterRenderQuestion={this.onAfterRenderQuestion}
data={this.props.surveyData}
onCompleting={this.onBeforeCompleting}
locale="de"
surveyCss="bootstrapmaterial"
onValueChanged={this.props.cachingData}
mode={this.props.surveyDisplayMode}
/>
);
}
}
Any ideas what needs to be considered would be very helpful!. If you need more Information, just let me know!
Best wishes
Karina