Select to view content in your preferred language

Can't open Survey123 URLs in Field Maps popup after rebuilding in New Map Viewer

542
1
10-29-2024 05:37 PM
KetaLegacy
New Contributor

EDIT: Hey y'all - turns out to save space my phone uninstalled Survey123 recently, which is why the link wasn't working. After reinstalling Survey123 these links work no problem. Problem solved 🙃

Hello,

I'm trying to use a arcgis-survey123:// URL to pass some data from a Field Maps feature into a Survey123 form, but the link isn't working on the field app (iOS).

In Map Viewer Classic, I could set up a custom attribute display and use some HTML like the following to create a clickable button that invoked S123 and passed some attributes:

From Survey123 URL Generator

 

<a href="arcgis-survey123://?itemID=ff70663e06e2456bac578886431ae7dc&field:guid={GlobalID}"><img src="https://dabuttonfactory.com/button.png?t=Add+Data+to+Subplot&f=Roboto-Bold&ts=24&tc=fff&tshs=1&tshc=000&hp=20&vp=8&c=5&bgt=gradient&bgc=6aa84f&ebgc=274e13&shs=1&shc=444&sho=s" alt="Add Data to Subplot"></a>

 

 

The above method has worked with Map Viewer Classic for a few years. This year we designed a new field map using the new map viewer, but the old expression isn't working anymore.

I've tried building the pop-up expression a few ways:
- I've tried embedding the above HTML button in a pop-up text element
- I've tried constructing the S123 URL in an Arcade expression, then invoking the returned text as an HTML text element in the pop-up
- I've tried placing the survey123 url as plaintext in the pop-up, but it's not clickable
- I've tried hyperlinking the S123 URL to plaintext, but it has the same strange non-clickable behavior as the button
- I've tried using both URL formats https://survey123.arcgis.app and arcgis-survey123://?

The strange behavior (see attached video): When I interact with the button or link, it seems like it's being treated as an image. Short pressing the button tries to highlight the button text. Long pressing the edges of the button "grabs" it as if it were an image, but also shows a preview to a correct-looking arcgis-survey123:// link. Previously I could just tap this button and Survey123 would open to the linked survey on my device.

Other hyperlinks seem to work fine (e.g, 'www.google.com', or just 'google' hyperlinked to that address) - one tap opens the link in my mobile browser as expected.

Arcade expression:

 

 

 

// Define the itemID and field parameter
var itemID = "ff70663e06e2456bac578886431ae7dc";
var guidField = $feature.GlobalID;

// Construct the URL
var s123URL = "arcgis-survey123://" + "?itemID=" + itemID + "&field:guid=" + guidField;

// Return the constructed URL
return s123URL;

 

 

 

 

Returns this URL: 

text: "arcgis-survey123://?itemID=ff70663e06e2456bac578886431ae7dc&field:guid=2950fa9a-c9da-4ba3-aeb7-6823244c91d7"

Which I try to invoke in this expression in a text element in the pop-up:

 

 

 

<p>
    <a href="{expression/expr2}" target="_blank"><img src="https://dabuttonfactory.com/button.png?t=Add+Data+to+Subplot&amp;f=Roboto-Bold&amp;ts=24&amp;tc=fff&amp;tshs=1&amp;tshc=000&amp;hp=20&amp;vp=8&amp;c=5&amp;bgt=gradient&amp;bgc=6aa84f&amp;ebgc=274e13&amp;shs=1&amp;shc=444&amp;sho=s" alt="Add Data to Subplot"></a>
</p>

 

 

 

 

Thanks for any help!

0 Kudos
1 Reply
ChristopherCounsell
MVP Regular Contributor

I've found the most foolproof thing you can do is encode the entire URL in an Arcade expression, then return it as text in an Arcade block, or as an expression {expression/expr0}  as a link value in your text.

 

// Optional function to include coordinates
function WebMercatorToWGS84 (x, y) {
    var lon = (x / 20037508.34) * 180;
    var lat = (y / 20037508.34) * 180;
    lat = 180/PI * (2 * Atan(Exp(lat * PI / 180)) - PI / 2);

    return {
        y: lat,
        x: lon
    }
}

// set source of app
var urlsource = 'arcgis-survey123://?';
// set parameters
var params = {
  // update itemid of survey
  itemID: 'xxxxxxxxxxxxxxxxxxxxxxx',
  // update parameters like fields
  "field:parentglobalid":$feature["globalid"],
  "field:surveyfield":$feature["featurefield"],
  // optional coordinates using earlier function
  center: coords.y + "," + coords.x,
  // Optional callback to field maps
  callback:'https://fieldmaps.arcgis.app'
};

// Construct and encode URL
var customurl = urlsource + UrlEncode(params)

// if returning as expression
return customurl

// if returning as content block, delete above and us this:

return{
  type: 'text',
  text: `<p style="text-align:center;"><a style="background-color:rgb(0, 0, 255);border-radius:0.5em;box-shadow:rgba(0, 0, 0, 0.2) 0px 1px 2px;color:rgb(255, 255, 255) !important;cursor:pointer;display:inline-block;font-family:Arial, Helvetica, sans-serif;font-stretch:normal;font-style:normal;font-variant:normal;font-weight:normal;line-height:100%;outline:none;padding:0.5em 0.8em;text-align:center;text-decoration:none;text-shadow:rgba(0, 0, 0, 0.3) 0px 1px 1px;" href=${customurl}><span style="font-size:large;">TEXT USER SEES</a></p>`
}