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:
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FeatureFormViewModel.html#setValue
Here is the app.
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.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.