My widget code runs well with the correct result. But I see the reference error in Console Window – it says countyFeatureLayer is not defined.
My widget is to show the query result in Attribute table. I use two queries – the first query is to check if the drawbox-polygon is inside the state boundary. The second query is to intersect with countyFeatureLayer to get the county attribute info. Reading questions in the forum, I use SelectFeatures and show the query result in attribute table.
I define countyFeatureLayer in postCreate. In _onDrawComplete function, I just countyFeatureLayer.selectFeatures. My code does not have the error before using SelectFeatures. Also, I checked my reference, which is same as my sandbox code. I do not know why I get the reference error. See the screenshot.
I also attach my widget zip files.