Select to view content in your preferred language

Creating Runtime Datasources in Experience Builder 1.19

172
3
Jump to solution
2 weeks ago
JeffreyThompson2
MVP Frequent Contributor

I just updated to 1.19 and I have encountered a major issue with creating runtime datasources. Something has changed in the coding path as my Custom Widget was working in 1.18. I don't see anything related to this documented in the Breaking Changes. The behavior I am getting is extremely odd. The layers created this way will first load as expected then unload themselves in Preview Mode. See screen recording:

Stranger still, this does not happen in the Build Mode. The layers do not automatically unload even when using Live View and I can switch between sets of layers without issue. The advanced datasource functionality is not available in the Map Layers Widget, but the Select Widget works as expected.

JeffreyThompson2_0-1763155586883.png

I am able to use Select and send the results to a Table Widget in Live View.

JeffreyThompson2_1-1763155646978.png

I have not done much troubleshooting yet. I just wanted to get this question out so the Dev Team has something to think about over the weekend.

GIS Developer
City of Arlington, Texas
0 Kudos
1 Solution

Accepted Solutions
JeffreyThompson2
MVP Frequent Contributor

Well, I don't fully understand what's going on here and I don't think this solution will be helpful to anyone else, but I will try to explain what I have found the best I can.

In my Widget, I would first load a set of FeatureLayers and sometimes other layer types bundled as a GroupLayer, then loop through the GroupLayer and create Datasources for the FeatureLayers individually. This would cause two copies of the layers to load, one in a Group and the other with a Datasource. So I would remove the GroupLayer to get it back to a single copy. Was that the best way to do this? I don't know. Probably not. But it was effective in Experience Builder 1.14-18.

There was some historic reason behind the code operating this way as, I had been grouping the layers back in 1.12, but I discovered that I could not use GroupLayers as Datasources when I starting turning them into Datasources in 1.14.

In 1.19, it appears that the dataSourceJsonCreator.createDataSourceJsonByJSAPILayer() function does not work with FeatureLayers within a GroupLayer. But, you can pass the entire GroupLayer into the function and get a valid Datasource for the component layers with the layers in a GroupLayer.

It's still super weird that I am getting different results in Live View vs. Preview. I have no idea what that is about.

The version of the Widget on ESRI Community does not have this issue and appears to still work as expected.

GIS Developer
City of Arlington, Texas

View solution in original post

0 Kudos
3 Replies
ericsamson_tract
Frequent Contributor

Hey Jeffrey, somewhat unrelated but did you have issues importing 1.18 applications into 1.19? I posted about it here: 
https://community.esri.com/t5/arcgis-experience-builder-questions/can-t-import-1-18-experiences-into...

I also have a bunch of widgets that utilize runtime datasources, so probably will be broken for me when I am finally able to update.

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

It appears that my projects upgraded without issue. Although, a number of Widgets broke in the upgrade. In addition to the issue above, I needed to fix the import statements for all my Widgets using the Components API. I also forked off the ESRI Search Widget back in Experience Builder 1.10-1.12 and it refused to load after the update. I'm not very surprised that happened and I have not started looking into that problem at all.

I have not gotten back to troubleshooting my upgrade yet.

GIS Developer
City of Arlington, Texas
0 Kudos
JeffreyThompson2
MVP Frequent Contributor

Well, I don't fully understand what's going on here and I don't think this solution will be helpful to anyone else, but I will try to explain what I have found the best I can.

In my Widget, I would first load a set of FeatureLayers and sometimes other layer types bundled as a GroupLayer, then loop through the GroupLayer and create Datasources for the FeatureLayers individually. This would cause two copies of the layers to load, one in a Group and the other with a Datasource. So I would remove the GroupLayer to get it back to a single copy. Was that the best way to do this? I don't know. Probably not. But it was effective in Experience Builder 1.14-18.

There was some historic reason behind the code operating this way as, I had been grouping the layers back in 1.12, but I discovered that I could not use GroupLayers as Datasources when I starting turning them into Datasources in 1.14.

In 1.19, it appears that the dataSourceJsonCreator.createDataSourceJsonByJSAPILayer() function does not work with FeatureLayers within a GroupLayer. But, you can pass the entire GroupLayer into the function and get a valid Datasource for the component layers with the layers in a GroupLayer.

It's still super weird that I am getting different results in Live View vs. Preview. I have no idea what that is about.

The version of the Widget on ESRI Community does not have this issue and appears to still work as expected.

GIS Developer
City of Arlington, Texas
0 Kudos