I have this simple JS app and trying to preset the value of a field. On this example is the Phone Number field but I want to know what am I doing wrong and I can't preset it using the setValue property.
This is the property:
Solved! Go to Solution.
I found adding a bit of asynchronous delay seems to do the trick:
editorVM.watch(['state', 'featureFormViewModel.feature', 'featureFormViewModel.state'], () => {
if (editorVM.state == 'creating-features' && editorVM.featureFormViewModel.feature && editorVM.featureFormViewModel.state == 'ready') {
window.setTimeout(function() {
editorVM.featureFormViewModel.setValue('PhoneNumber', "999.999.999")
}, 200);
}
});
You'll want to be careful this workflow doesn't inadvertently overwrite something the user manually enters; I didn't test for that kind of thing.
I found adding a bit of asynchronous delay seems to do the trick:
editorVM.watch(['state', 'featureFormViewModel.feature', 'featureFormViewModel.state'], () => {
if (editorVM.state == 'creating-features' && editorVM.featureFormViewModel.feature && editorVM.featureFormViewModel.state == 'ready') {
window.setTimeout(function() {
editorVM.featureFormViewModel.setValue('PhoneNumber', "999.999.999")
}, 200);
}
});
You'll want to be careful this workflow doesn't inadvertently overwrite something the user manually enters; I didn't test for that kind of thing.