Arcade Popup content is not show in portal

287
6
03-20-2024 06:22 AM
DRae
by
New Contributor III

Hi, I have configure the Popup for the layer in the ArcGIS Pro and one of the field is using Arcade, and it is working to show dynamic attachments. The arcade script as below. It is working fine in ArcGIS Pro.

 

var layer = "https://somserver.com/server/rest/services/mylayer/myfeature_PT/MapServer/0/";
var attachs = Attachments($feature);
var acount = Count(attachs);
var html = '';
var foid = $feature.objectid;
for(var i=0; i < acount; i++){
var att = attachs[i];
var attoid = att.id;
var atturl = layer + foid + "/attachments/" + attoid
var attname = att.name
html = html + "<a href='" + atturl + "' target='_blank'>" + attname + "</a>" + '<br />';
}
return { 
  	type : 'text', 
text : html
}

However, after the layer upload to our portal server, and I check the popup. The  arcade expression code is empty.

Capture.JPG

0 Kudos
6 Replies
jcarlson
MVP Esteemed Contributor

Hard to say, but I think the href needs double quotes? The way Pro evaluates popups is very different from the web map sometimes.

Here are a couple things to try:

First, push your attachment URLs into an array, then use Concatenate to return a formatted block of text.

Second, use template literals to build your HTML strings. This will avoid any issues with quotation marks.

var layer = "https://somserver.com/server/rest/services/mylayer/myfeature_PT/MapServer/0/"
var attachs = Attachments($feature)
var foid = $feature.objectid
var link_arr = []

for(var a in attachs) {
  var atturl = `${layer}${foid}/attachments/${attachs[a].id}`
  var attname = attachs[a].name
  var link = `<a href="${atturl}" target="_blank">${attname}</a>`
  Push(link_arr, link)
}

var links = Concatenate(link_arr, '<br>')

return { 
  type : 'text', 
  text : links
}
- Josh Carlson
Kendall County GIS
0 Kudos
DRae
by
New Contributor III

I tried it and it is still not show any attachments link on it.

0 Kudos
jcarlson
MVP Esteemed Contributor

And you can confirm that there are actually attachments on the given feature? Try adding the count of the attachments array to the output, just to check. When you create the array, put the count in as the first item:

var link_arr = [`${Count(attachs)} attachments:`]

 Do you see a count of items?

Also, try putting some static text in the HTML. The attachments ought to all have names, but if the attname variable were empty, the link wouldn't render.

var link = `<a href="${atturl}" target="_blank">File: ${attname}</a>`

Any change?

- Josh Carlson
Kendall County GIS
0 Kudos
DRae
by
New Contributor III

In the portal, the count is show 0, why?

0 Kudos
jcarlson
MVP Esteemed Contributor

For whatever reason, it's just not seeing attachments on the feature, if there are any. Are you using a View Layer? It's possible to have a view layer that doesn't expose the attachments of the source data.

I would open the data table in your Portal to confirm that there are attachments on the features. I'd also take a look at the layer properties in Pro, just to make sure that Pro and Portal are referencing the same exact data source. If you're using views, or if you published the layer from Pro, it's possible that they're not looking at the same data.

- Josh Carlson
Kendall County GIS
0 Kudos
DRae
by
New Contributor III

From the table in portal, I can see the number of attachments column. Capture1.JPG

0 Kudos