Viewing Related Records in attribute table Web AppBuilder

2558
6
Jump to solution
09-29-2016 02:48 PM
ChristopherSchreiber
Occasional Contributor II

Hello all,

I am trying to view related data in the attribute table widget in Web AppBuilder. It is a one-to-many relationship and everything works fine on the ArcGIS Online webmap. When I try the same thing in Web AppBuilder, the Attribute table widget comes back with "No related records found" but I know that there are records. The related records are stored in a table that is hosted on ArcGIS Online.

When I open the browser dev tools I see this error:

Error: Invalid URL

I do not have the table showing in the attribute table by default. I am not sure if this is causing the issue.

Thanks!

Chris

0 Kudos
1 Solution

Accepted Solutions
ChristopherSchreiber
Occasional Contributor II

Hello all, 

I contacted Esri support and they were able to help me with this issue.

The problem was not the proxy, the reason that I was getting "Invalid URL" errors in the console was because the app was changing the URL from

www.myorg.maps.arcgis.com/<orgcode>/arcgis/rest/services/<service>/FeatureServer/0

to 

www.myorg.maps.arcgis.com/<orgcode>/arcgis/rest/services/<service>/MapServer/0

Map services cannot be hosted on ArcGIS Online, so this was causing my error. 

Tech support and I looked at apps hosted on AGOL and were not able to reproduce this error. This seems to be an issue with Web AppBuilder Developer Edition Version  2.1. ArcGIS Online is running the next version of WAB.

The helpful folks at Esri support were able to provide a work-around for the issue:

In the proxy.ashx file, add the following (around line 114):

        //if url is encoded, decode it.
        if (uri.StartsWith("http%3a%2f%2f", StringComparison.InvariantCultureIgnoreCase) || uri.StartsWith("https%3a%2f%2f", StringComparison.InvariantCultureIgnoreCase))
            uri = HttpUtility.UrlDecode(uri);
        //Esri Support work around
        if (uri.StartsWith("https://services.arcgis.com/<orgcode>/arcgis/rest/services/<MyService>/MapServer", StringComparison.InvariantCultureIgnoreCase))
        {
            uri = uri.Replace("MapServer", "FeatureServer");
        }
        //End Work around
        log(TraceLevel.Info, uri);
        ServerUrl serverUrl;
        try {‍‍‍‍‍‍‍‍‍‍‍‍

This addition basically waits for this URL to pass through the proxy and then when it sees it, it replaces 'MapServer' with 'FeatureServer' and sends it on its merry way.

Esri support created bug for the issue:

 

#BUG-000099764

Fail to query related table from web appbuilder app, the request is made through Map Server instead of Feature Server after applying proxy to the app

Thanks!

Chris

View solution in original post

6 Replies
ChristopherSchreiber
Occasional Contributor II

Hello all,

I have been working on this and I think I found out why I am having issues.

After comparing the network traffic with Fiddler web debugger between the app that is not working and one on AGOL that works, I found that the difference between the tow was that the local app (not working one) was using a proxy and the proxy was not including a token on the end of the URL. 

This is further confirmed when I run the app with out any proxy settings and log in when it loads. If I do it this way, no issues, but when I use the proxy, it will not load related data.

If anyone has come across this issue and worked around it, please let me know.

Thanks!

Chris

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Christopher,


  I believe that this is a known Proxy issue with passing tokens. I would give tech support a call to confirm.

ChristopherSchreiber
Occasional Contributor II

Thanks Robert, 

I will give them a call.

Chris

0 Kudos
ChristopherSchreiber
Occasional Contributor II

Hello all, 

I contacted Esri support and they were able to help me with this issue.

The problem was not the proxy, the reason that I was getting "Invalid URL" errors in the console was because the app was changing the URL from

www.myorg.maps.arcgis.com/<orgcode>/arcgis/rest/services/<service>/FeatureServer/0

to 

www.myorg.maps.arcgis.com/<orgcode>/arcgis/rest/services/<service>/MapServer/0

Map services cannot be hosted on ArcGIS Online, so this was causing my error. 

Tech support and I looked at apps hosted on AGOL and were not able to reproduce this error. This seems to be an issue with Web AppBuilder Developer Edition Version  2.1. ArcGIS Online is running the next version of WAB.

The helpful folks at Esri support were able to provide a work-around for the issue:

In the proxy.ashx file, add the following (around line 114):

        //if url is encoded, decode it.
        if (uri.StartsWith("http%3a%2f%2f", StringComparison.InvariantCultureIgnoreCase) || uri.StartsWith("https%3a%2f%2f", StringComparison.InvariantCultureIgnoreCase))
            uri = HttpUtility.UrlDecode(uri);
        //Esri Support work around
        if (uri.StartsWith("https://services.arcgis.com/<orgcode>/arcgis/rest/services/<MyService>/MapServer", StringComparison.InvariantCultureIgnoreCase))
        {
            uri = uri.Replace("MapServer", "FeatureServer");
        }
        //End Work around
        log(TraceLevel.Info, uri);
        ServerUrl serverUrl;
        try {‍‍‍‍‍‍‍‍‍‍‍‍

This addition basically waits for this URL to pass through the proxy and then when it sees it, it replaces 'MapServer' with 'FeatureServer' and sends it on its merry way.

Esri support created bug for the issue:

 

#BUG-000099764

Fail to query related table from web appbuilder app, the request is made through Map Server instead of Feature Server after applying proxy to the app

Thanks!

Chris

ChristopherSchreiber
Occasional Contributor II
ChristopherSchreiber
Occasional Contributor II

Hello all, 

I found this solution for those applications that do not use a proxy. 

        //working around an arcgis server feature service bug.  Requests to queryRelatedRecords operation fail with feature service 10.
        //Detect if request conatins the queryRelatedRecords operation and then change the source url for that request to the corresponding mapservice
        esriRequest.setRequestPreCallback(function(ioArgs) {
          if (ioArgs.url.indexOf("queryRelatedRecords") !== -1) {
            ioArgs.url = ioArgs.url.replace("FeatureServer", "MapServer");
          }
          return ioArgs;
        });

It intercepts the request like the proxy and changes the URL. 

This was found on this site: Query and edit related records | ArcGIS API for JavaScript 3.20 

Thanks, 

Chris