I have a use case that calls for making an API call to a document management system (OTIS) to retrieve URLs of documents in OTIS and display in the popup of a clicked feature of a web map. The GISID of the feature is passed in the API call that searches OTIS for the docs corresponding to that GISID. The API call requires authentication so I cannot use Arcade.
The web map is an existing web map (let's call it Wastewater) that was created using the enterprise portal Map Viewer. I was able to load Wastewater in a staging page using webmap.load() and include code in the staging page to dynamically handle a click on a feature to return the corresponding document URLs from OTIS. I included a webmap.save() in the code. The result is, after launching the page, clicking some features and verifying that the correct doc URLs corresponding to the clicked features returned by OTIS and displayed in the popups, what is saved in the Wastewater web map popup configuration is the URLs of the last feature I clicked on. I.e. when I look at the web map's popup configuration in the Portal Map Viewer, I see the URLs of the last feature click on.
Any help or tips on how to implement my use case on an existing web map would be greatly appreciated. I am trying to avoid recreating, using code, the entire web map which has many sublayers requiring tedious popups and widgets configurations through code.