In 2017 Kelly Gerrow shared a great blog on https://community.esri.com/community/gis/web-gis/arcgisonline/blog/2017/07/18/conditional-field-disp... , but there are still a lot of questions on how to hide rows of a table that do not have values. In this document I will try to explain how to do this with Arcade in a web map.
I have a feature layer, added 3 fields and randomly created some data including null values:
The idea is to create a table that will show the 3 rows when all 3 field have a value and hides each row that are empty:
So how can we hide rows and not leaving empty lines? This can be done by using a style that shows or not shows the row, which can be conditionally done using Arcade. See below the HTML used in the example above:
Information before table<table><tbody>
<tr style="display:{expression/expr0}">
<td style="width:125px; text-align:left; background-color:#ede8e8; padding:5px">Description 1</td>
<td style="width:225px; text-align:left; background-color:#ede8e8; padding:5px">{Field1}</td>
</tr>
<tr style="display:{expression/expr1}">
<td style="width:125px; text-align:left; background-color:#ede8e8; padding:5px">Description 2</td>
<td style="width:225px; text-align:left; background-color:#ede8e8; padding:5px">{Field2}</td>
</tr>
<tr style="display:{expression/expr2}">
<td style="width:125px; text-align:left; background-color:#ede8e8; padding:5px">Description 3</td>
<td style="width:225px; text-align:left; background-color:#ede8e8; padding:5px">{Field3}</td>
</tr>
</tbody></table>Information after table
In this case there are 3 Arcade expressions. Each expression will validate if an attribute has a value or is empty. In case it is empty it will return "none" (hide the row) en in case it has a value it will return "block" (show the row). See below the expression to validate field 1 (the same is done for fields 2 and 3):
IIf(IsEmpty($feature.Field1), "none", "block");
If you have any questions, just post them below.
I am creating a custom table in my pop-up with Arcade and I have a field that I am combining three attributes to populate. If all three attributes are empty, I would like the row in the table to not show up. I've been reading your responses on a couple of other threads and they have helped me a lot, but I can't seem to get this one to work. Here is an example of my code...
I'm then using this arcade expression in my HTML as you showed above. Thank you for any help you can provide!
Hi Korin Miles ,
You could try something like this:
var val1 = IFF(IsEmpty($feature.supervisorName), 0, 1);
var val2 = IFF(IsEmpty($feature.supervisorPhone), 0, 1);
var val3 = IFF(IsEmpty($feature.supervisorEmail), 0, 1);
if (val1+val2+val3 == 0) {
return "none";
} else {
return "block";
}
It is important to remember that a return in a loop when hit, will exit the loop and in your case never be able to check for 3 empty values.
Thank you for your help! I ended doing this, and it worked great...
One thing that I did want to pass along, is that if you are trying to configure a table the "block" throws off the table alignment. I found this thread on stack overflow and it looks like the issue is that the <tr> style is not supported in HTML5. html - Why does not display:block and 100% width work on table rows? - Stack Overflow
"Block" works great if you are not using a table in the pop-up, but for a table, returning "table-row" is what gave me a row that was 100% of the table.
Hi kmmiles_usfs ,
Are you sure that this works correctly? You are assigning the text "true" which is not the same as True (boolean). Also you check if it is not equal to the text "none" and that will never be the case.
Buenas tardes, actualmente tengo unas ventanas emergentes creadas a partir de una encuesta de survey123, algunas de las casillas necesito que se oculten en caso de no escribir nada en ellas, como puedo hacer eso? porque leyendo esto entiendo que es crear cuadros emergentes a partir de cero y que permita ocultar las casillas vacías, pero necesito hacerlo con cuadros emergentes ya hechos por la encuesta de survey123 y poder ocultar esas casillas que no se les escribe nada por el hecho de que algunas no serán llenadas todo el tiempo.
Hola maria ibal ,
Tienes razón, esta manera es bastante complicado para hacer este proceso para múltiples campo y requiere multiples expresiones por campo. Es posible crear una sola expresión evaluado el contenido de los campos y devolver algo o nada. La desventaja es que no puedes cambiar mucho de la manera como se va a presentar los datos. Solamente será un texto con la misma fuenta, color, etc.
Xander,
You say there is an easier way to do this with multiple fields at a time in a single expression while sacrificing the ability to customize the font. Can you give an example please?
Hi JosephLivoti ,
Actually, you would end up sacrificing more than just the font. I would be just plain text that you return. Using the field names from what Korin showed above, an expression could be like this:
var result = "Information:";
if (!IsEmpty($feature.supervisorName)) {
result += TextFormatting.NewLine + "Supervisor Name: " + $feature.supervisorName;
}
if (!IsEmpty($feature.supervisorPhone)) {
result += TextFormatting.NewLine + "Supervisor Phone: " + $feature.supervisorPhone;
}
if (!IsEmpty($feature.supervisorEmail)) {
result += TextFormatting.NewLine + "Supervisor Email: " + $feature.supervisorEmail;
}
return result;
Remember, this just returns plain text. There will be better options in the near future. At the UC last week, the team mentioned that it will be possible to define visibility of attributes based on Arcade expressions.
Thank you for the reply. I was wondering if you could help on one other matter. I have gone and done things the LONG and TEDIOUS way. I have created over 200 individual IIF statements: ex IIF(isEmpty($feature.notes35), "", "Notes").
My popup currently looks like this:
How can I get rid of those fields that are empty?
Popup Expression currently is this:
with a total of 210 lines.
Any help would be greatly appreciated. I've looked at the other blogs and other questions people have asked and i just cant quite get it down.
-Joe
Hi Joe Livoti ,
First of all having a pop-up with 210 lines, might be a "little" big and not too user-friendly.
So if I understand you correctly, you have a long list of expressions, but some return an empty line. To avoid this you would have to put everything on a "single" line and include the "TextFormatting.NewLine" inside the expression in case you do have a result.
Again Thank you Xander Bakker for your reply.
I know it's seem quite unwieldy, but this pop-up is catered to an audience of one.
So am I to understand I can write one long expression and include "TextFormatting.NewLine" after each field? Where would i put the formatting? I apologize as my arcade skills are practically nil. What would the below example look like and can it still be formatted with the field name bold (i've included the individual IIF statements along with the how I have it set up in the Attribute display below that):
IIF(isEmpty($feature.status14), "", "Footer")
IIF(isEmpty($feature.status14), "", "Status")
IIF(isEmpty($feature.assignedto14), "", "Inspector")
IIF(isEmpty($feature.other14), "", "Other Inspector")
IIF(isEmpty($feature.date_approved14), "", "Date Approved")
IIF(isEmpty($feature.notes14), "", "Notes")
IIF(isEmpty($feature.status15), "", "Foundation")
IIF(isEmpty($feature.status15), "", "Status")
IIF(isEmpty($feature.assignedto15), "", "Inspector")
IIF(isEmpty($feature.other15), "", "Other Inspector")
IIF(isEmpty($feature.date_approved15), "", "Date Approved")
IIF(isEmpty($feature.notes15), "", "Notes")
{expression/expr5}
{expression/expr0} {status14}
{expression/expr1} {assignedto14}
{expression/expr2} {other14}
{expression/expr3} {date_approved14}
{expression/expr4} {notes14}
{expression/expr6}
{expression/expr7} {status15}
{expression/expr8} {assignedto15}
{expression/expr9} {other15}
{expression/expr10} {date_approved15}
{expression/expr11} {notes15}
Thank you again so very much for any help and advice!!
Hi Joe Livoti ,
You can use a single expression which reads out all the information and presents the result. The thing that you can't do is apply any formatting at different parts of the result. In you example you have expression single underlined and all expressions in bold. So, I think it might be better to adjust what you already have.
The individual expressions would become:
IIF(isEmpty($feature.status14), "", TextFormatting.NewLine + "Footer")
IIF(isEmpty($feature.status14), "", TextFormatting.NewLine + "Status")
IIF(isEmpty($feature.assignedto14), "", TextFormatting.NewLine + "Inspector")
IIF(isEmpty($feature.other14), "", TextFormatting.NewLine + "Other Inspector")
IIF(isEmpty($feature.date_approved14), "", TextFormatting.NewLine + "Date Approved")
IIF(isEmpty($feature.notes14), "", TextFormatting.NewLine + "Notes")
IIF(isEmpty($feature.status15), "", TextFormatting.NewLine + "Foundation")
IIF(isEmpty($feature.status15), "", TextFormatting.NewLine + "Status")
IIF(isEmpty($feature.assignedto15), "", TextFormatting.NewLine + "Inspector")
IIF(isEmpty($feature.other15), "", TextFormatting.NewLine + "Other Inspector")
IIF(isEmpty($feature.date_approved15), "", TextFormatting.NewLine + "Date Approved")
IIF(isEmpty($feature.notes15), "", TextFormatting.NewLine + "Notes")
...and the text in the pop-up would become a single line like this:
{expression/expr5}{expression/expr0} {status14}{expression/expr1} {assignedto14}{expression/expr2} {other14}{expression/expr3} {date_approved14}{expression/expr4} {notes14}{expression/expr6}{expression/expr7} {status15}{expression/expr8} {assignedto15}{expression/expr9} {other15}{expression/expr10} {date_approved15}{expression/expr11} {notes15}
In case a field is empty the expression will detect it and return an empty string which you wont see and which does not take up an empty line.
Thank you so much that did the trick exactly. While tedious, it formats the data exactly. Do you think there is a way to create a single arcade expression and then plug that into html for the formatting? Not asking you to figure it out, just if you think it is possible. If so, I may make that a project of mine to try and work on in the future. Again, thank you so very much for all of your help!
-Joe
Hi Joe Livoti ,
As I mentioned before there will be functionality in the near future to determine the visibility of a field using Arcade. I do not have any specifics at this moment about how this will work. In ArcGIS Pro you can create HTML and return it in an Arcade expression and it will visualize as you want. In ArcGIS Online, this is not possible yet, however, it is on the road map, since compatibility between the different components of the platform is very important. Currently, when you create html code in an Arcade expression in ArcGIS Online, it will be interpreted as plain text.
Hello Xander Bakker Bakker,
Any updates or specifics available yet on the future release that will have the ability to hide/display attribute fields using Arcade? We have been working with Survey 123 / Arcade to find a way to do exactly this while using ArcGIS Collector Offline. Thank you!
Hi David Little ,
Sorry to tell you, but I haven't heard anything yet. I also haven't entered the beta for the next ArcGIS Online release, so I am not sure if it will be included in the next update later this month.
Thank you,
Mr Xander Bakker @ XanderBakker, hope you could help me to figure out how to limit the empty (blank spot) if the amenities = No.
Link to my map: https://arcg.is/0SCaGy
I tried both blank image and a ' ' space, but all showing ugly
Case 1:
var checkvalue = $feature.ROADCYCLE
var img_blank = 'https://otrd.maps.arcgis.com/sharing/rest/content/items/a59adfcb8fec43b9a9c1de5b1e65f93c/data'
var img_show = 'https://otrd.maps.arcgis.com/sharing/rest/content/items/52d5725bf8cf47dc94861d057ac2936d/data'
iif(checkvalue =='Yes',img_show,img_blank)
Case 2:
var checkvalue = $feature.ARCHERY
var img_show = 'https://otrd.maps.arcgis.com/sharing/rest/content/items/496f45f58b8a483c961c00b1f67efe95/data'
iif(checkvalue =='Yes',img_show,' ')
I already have a custom attribute display, is there a way to add an attribute expression where in my current custom attribute display, certain fields don't show if they equal 0?
I have read all the Arcade Expression help pages and forums, but do not see anything on having the "return" be blank.
Thoughts anyone?
Hi, I copied your code and tried to apply to my work, with no success. It stills shows the empty rows (title in the first column and empty attribute in the second). Could it be the version of Portal for ArcGIS (7.1)?
I did as follows, I have an expression for "Location" and another for "Region". When it failed I tried the variant, that also failed.
arcade expression -
IIF (IsEmpty($feature.Location), "", "block");
// variant
var arrName = $feature.Location
for (var i in arrName) {
if(arrName[i]==NULL) {return"none"}
}
return "block"
The HTML expression
<table><tbody> <tr style="display:{expression/expr0}"> <td style="width:125px; text-align:left; background-color:#ede8e8; padding:5px">Location</td> <td style="width:225px; text-align:left; background-color:#ede8e8; padding:5px">{Location}</td> </tr> <tr style="display:{expression/expr1}"> <td style="width:125px; text-align:left; background-color:#ede8e8; padding:5px">Region</td> <td style="width:225px; text-align:left; background-color:#ede8e8; padding:5px">{Region}</td> </tr> </tbody> </table>
Cheers,
Pedro
Hi @XanderBakker your tutorials on conditional images in pop-ups have really helped me!! I was wondering if it's possible to hide cells rather than rows if the field value is empty?
Here's my arcade expression that looks at an attribute to see if a specific value is there
var txt = Replace($feature["Activity2"], " ", "");
var lst = Split(txt, ",");
if (IndexOf(lst, "hiking") > -1) {
return "block";
} else {
return "none";
}
Here's the html code for the table where the images with links will be displayed, although unfortunately it doesn't seem to work. The conditional images show up, but it's not formatted as a single row table.
<table style="border-collapse:collapse; width:100%">
<tbody>
<tr>
<td style="display:{expression/expr0}"><a href=""><img alt="hiking" src="" /></a></td>
<td style="display:{expression/expr1}"><a href=""><img alt="cycling" src="" /></a></td>
<td style="display:{expression/expr2}"><a href=""><img alt="dog walking" src="" /></a></td>
<td style="display:{expression/expr3}"><a href=""><img alt="photography and filming" src="" /></a></td>
<td style="display:{expression/expr4}"><a href=""><img alt="birding" src="" /></a></td>
<td style="display:{expression/expr8}"><a href=""><img alt="kicksledding" src="" /></a></td>
<td style="display:{expression/expr7}"><a href=""><img alt="fat tire biking" src="" /></a></td>
<td style="display:{expression/expr5}"><a href=""><img alt="snoeshoeing" src="" /></a></td>
<td style="display:{expression/expr6}"><a href=""><img alt="cross-county skiing" src="" /></a></td>
</tr>
</tbody>
</table>
Thank you very much for your help!
Hi @AJ_devaccount ,
I think your expression is hiding the columns (or cell data elements). The challenge is that the images will appear each on a new row. This is more an HTML question than an Arcade question. I did some quick tests and none of them resulted in having the cells appear on a single row. So if you can solve this HTML issue and incorporate it in the Arcade expression it should work.
And just when I am about to post this I noticed that there is something you could do; use a single cell (column) and change the display "block" to "inline-block" inside the img tag. Have a look at the example below (just HTML no Arcade):
<HTML>
<header>
</header>
<body>
<table style="table-layout:fixed" width="1000px">
<tr style="white-space: nowrap; overflow: hidden;">
<td>
<a href=""><img style="display:inline-block;" alt="hiking" src=""/></a>
<a href=""><img style="display:none;" alt="cycling" src=""/></a>
<a href=""><img style="display:inline-block;" alt="dog walking" src=""/></a>
<a href=""><img style="display:inline-block;" alt="photography and filming" src=""/></a>
<a href=""><img style="display:inline-block;" alt="birding" src=""/></a>
<a href=""><img style="display:none;" alt="kicksledding" src=""/></a>
<a href=""><img style="display:none;" alt="fat tire biking" src=""/></a>
<a href=""><img style="display:none;" alt="snoeshoeing" src=""/></a>
<a href=""><img style="display:inline-block;" alt="cross-county skiing" src=""/></a>
</td>
</tr>
</table>
</body>
</HTML>
Hello!
I'm working in the new Map Viewer, and have a layer with 49 features and 24 fields. None of the features have all of the possible attributes/fields populated, so like everyone else, I'm trying to configure the popup to only display rows where the field is populated. I have practically zero experience using custom expressions, but I *think* I understand the Arcade expression given by @XanderBakker above:
IIf(IsEmpty($feature.Field1), "none", "block");
So I would have to repeat this expression 24 times, once for each field, correct? And each would be saved as {expression/expr0}, {expression/expr1}, ... etc.? Do I add those in the Properties pane under PopUps/Options/Manage Expressions/Add Expressions or under PopUps/Options/Arcade (custom)/edit expression?
And then "block" refers to the HTML code (which would also need to be repeated 24 times)? I don't understand where to build/store that.
Will Xander's HTML codeblock above return the default table view, but only rows with populated fields?
Thanks so much for any advice here, I'm looking forward to learning how to do this!
Hi @KateRose ,
Sorry for the delay in my reply. A couple of comments that I believe are relevant.
First of all, since December last year, you can define Arcade in two areas of the pop-up. The one that is most common works like a "virtual field" and can be used to create new information in the pop-up and, as described in this post, has been "abused" to hide information too. To hide 24 fields would require that you have many Arcade expressions and this would take up quite some time to configure.
With the December update, it has become possible to define an Arcade element and add it to the pop-up. It is possible to return a field list in a single Arcade expression.
See the example below:
var flds = ['Actividad', 'actividad_con', 'califique_la_actividad', 'campa_a', 'clasificaci_n_de_actividad', 'descripci_n_evento_y_contenido_', 'describe_la_soluci_n_ofrecida', 'empresa', 'fecha_de_actividad'];
var info = [];
var atts = {};
for (var i in flds) {
var fldname = flds[i];
if (!IsEmpty($feature[fldname])) {
Push (info, {'fieldName': fldname})
atts[fldname] = $feature[fldname];
}
}
return {
type: 'fields',
title: 'My Title',
description : 'My description',
fieldInfos: info,
attributes : atts
}
In this case, I start with a list of fields and I build an array with my field names (if you aren't empty) and a dictionary with the field values. The interpretation of the expression will present the result as a list of fields (but only those that have values).
This will return the actual values and names of the field. So no conversion for domain descriptions of aliases for the fields.
So you can have a little more fun and get all the fields that have values dynamically and return the alias as field "name" and the domain descriptions if a field has a domain:
Function HasDomain(f, fldname) {
return Domain(f, fldname) != Null;
}
Function GetAlias(f, fldname) {
var esquema = Schema(f);
var flds = esquema["fields"];
for (var i in flds) {
var fldinfo = flds[i];
if (fldinfo["name"]==fldname) {
return fldinfo["alias"];
}
}
return fldname;
}
Function GetFieldNames(f) {
var fldlst = [];
var esquema = Schema(f);
var flds = esquema["fields"];
for (var i in flds) {
var fldinfo = flds[i];
Push(fldlst, fldinfo["name"]);
}
return fldlst;
}
var flds = GetFieldNames($feature);
var info = [];
var atts = {};
for (var i in flds) {
var fldname = flds[i];
if (!IsEmpty($feature[fldname])) {
var alias = GetAlias($feature, fldname);
Push (info, {'fieldName': alias})
if (HasDomain($feature, fldname)) {
atts[alias] = DomainName($feature, fldname);
} else {
atts[alias] = $feature[fldname];
}
}
}
return {
type: 'fields',
title: 'My Title',
description : 'My description',
fieldInfos: info,
attributes : atts
}
But maybe you don't want to include all the fields in the result. In that case you can put those fields in a list and have the expression exclude those fields from the result, like this:
Function HasDomain(f, fldname) {
return Domain(f, fldname) != Null;
}
Function GetAlias(f, fldname) {
var esquema = Schema(f);
var flds = esquema["fields"];
for (var i in flds) {
var fldinfo = flds[i];
if (fldinfo["name"]==fldname) {
return fldinfo["alias"];
}
}
return fldname;
}
Function GetFieldNames(f, excludeflds) {
var fldlst = [];
var esquema = Schema(f);
var flds = esquema["fields"];
for (var i in flds) {
var fldinfo = flds[i];
if (!Includes(excludeflds, fldinfo["name"])) {
Push(fldlst, fldinfo["name"]);
}
}
return fldlst;
}
var excludeflds = ['globalid', 'objectid'];
var flds = GetFieldNames($feature, excludeflds);
var info = [];
var atts = {};
for (var i in flds) {
var fldname = flds[i];
if (!IsEmpty($feature[fldname])) {
var alias = GetAlias($feature, fldname);
Push (info, {'fieldName': alias})
if (HasDomain($feature, fldname)) {
atts[alias] = DomainName($feature, fldname);
} else {
atts[alias] = $feature[fldname];
}
}
}
return {
type: 'fields',
title: 'My Title',
description : 'My description',
fieldInfos: info,
attributes : atts
}
Hi @XanderBakker -
Thanks for the reply. Yes, since I wrote that post I found this Esri Lesson that describes how to work with the new features in Arcade. I also got help from a colleague who suggested I try this (which is similar to the scripts you shared above)
var fieldInfos = []
if (!IsEmpty ($feature.C1)) {
Push (fieldInfos, {fieldName: 'C1'})
};
if (!IsEmpty ($feature.C2)) {
Push (fieldInfos, {fieldName: 'C2'})
};
if (!IsEmpty ($feature.C3)) {
Push (fieldInfos, {fieldName: 'C3'})
};
if (!IsEmpty ($feature.C4)) {
Push (fieldInfos, {fieldName: 'C4'})
};
if (!IsEmpty ($feature.MOD1)) {
Push (fieldInfos, {fieldName: 'MOD1'})
};
if (!IsEmpty ($feature.MOD2)) {
Push (fieldInfos, {fieldName: 'MOD2'})
};
if (!IsEmpty ($feature.MOD3)) {
Push (fieldInfos, {fieldName: 'MOD3'})
};
if (!IsEmpty ($feature.MOD4)) {
Push (fieldInfos, {fieldName: 'MOD4'})
};
if (!IsEmpty ($feature.MOD5)) {
Push (fieldInfos, {fieldName: 'MOD5'})
};
return {
type: 'fields',
description: $feature.DESCRIP,
fieldInfos: fieldInfos,
attributes: {
'C1': $feature.C1,
'C2': $feature.C2,
'C3': $feature.C3,
'C4': $feature.C4,
'MOD1': $feature.MOD1,
'MOD2': $feature.MOD2,
'MOD3': $feature.MOD3,
'MOD4': $feature.MOD4,
'MOD5': $feature.MOD5
} // replace this dictionary with your own key-value pairs
}
But the popups show that some of the empty fields/rows are filtered out but some are not. The first popup shown here is for the first feature, and is the one that is tested in the expression builder, which shows that it builds an array of 9 attributes and dictionary pairs... but shouldn't the array for this feature only have an array of 4 attributes, since if the others are empty they shouldn't be pushed to the array?
I also tried modifying the first script you sent, which again builds an array of 9 fields & dictionary, but then the popups don't return any fields or even the Description, so I'm definitely doing something wrong... but since I'm very inexperienced, I don't know what it is... I'm probably not naming or listing the variables correctly? I would like to get this correct before trying the other script you sent, since I do want to display the field aliases instead of the field names.
Thanks so much!
var flds = ['C1', 'C2', 'C3', 'C4', 'MOD1', 'MOD2', 'MOD3', 'MOD4', 'MOD5'];
var info = [];
var atts = {};
for (var i in flds) {
var fldname = flds[i];
if (!IsEmpty($feature[fldname])) {
Push (info, {'fieldName': fldname})
atts[fldname] = $feature[fldname];
}
}
return {
type: 'fields',
description : $feature.DESCRIP,
fieldInfos: info,
attributes : atts
}
Hi @XanderBakker ,
My colleague came up with this solution, which works perfectly. He added the Trim function to each string to eliminate the whitespace, which is necessary for IsEmpty to work on non-empty strings. And also the label in order to return the field alias.
Thank you!!
var fieldInfos = []
if (!IsEmpty (Trim($feature.C1))) {
Push (fieldInfos, {fieldName: 'C1', label: 'Component'})
};
if (!IsEmpty (Trim($feature.C2))) {
Push (fieldInfos, {fieldName: 'C2', label: 'Component'})
};
if (!IsEmpty (Trim($feature.C3))) {
Push (fieldInfos, {fieldName: 'C3', label: 'Component'})
};
if (!IsEmpty (Trim($feature.C4))) {
Push (fieldInfos, {fieldName: 'C4', label: 'Component'})
};
return {
type: 'fields',
description: $feature.DESCRIP,
fieldInfos: fieldInfos,
attributes: {
'C1': $feature.C1,
'C2': $feature.C2,
'C3': $feature.C3,
'C4': $feature.C4
}
}
Hi @KateRose ,
Thanks for sharing and sorry for the delay in my reply. this would have been my first thought. When IsEmpty does not detect a field as empty, it normally is a white space. Trim does a good job in removing those spaces. I am glad you and your colleague were able to solve it!
Thanks for this post - super helpful! I was able to utilize this to hide empty fields as necessary in my pop-ups.
I am now trying to add in an expression that will conditionally show a linked url. The issue I'm running into is that the condition is not based on an empty field, but rather a field that has a specific value. Is there a way to do this? If I use the IIF function, then I can get the url to display conditionally but I am unable to make it into a link...
Any help or guidance would be much appreciated!
@JohnBornsworth did you ever get a response or solution to your last post? I am also trying to figure out how to do this same type of thing but with a spcific value-
ex:
status field has values of: Submitted, Approved, Needs Review, Closed
"This Incident Report {ID Value} is being reviewed by ES Incident Committee. More information will be available when review is complete."
Work Group: {WorkGroupC}
Nature of Interaction: {NatureInteractionOtherC}
Description: {IncidentDescriptionC}
Was 911 called: {Called911C}
Corrective Action: {Corrective_Action}
ID: {ID Value}
@VanessaSimps I am trying to do the same thing, any luck?
@Adam_Bourque - no, I adjusted what I was doing and scrapped this idea. I couldn't figure it out!
Thank you for your post, I modified your expression to hide null values (We have 102 fields and often only 1-2 have a value entered).
(I am new to Esri)
It seemed to work & I could view just the fields which had values (number of mosquitoes collected of each species type & at what life stage (Larvae 1-4 or adult F/M).
However then the species information disappeared & I can only see the title & field list. I can't see how to turn 'off or on' the expression to display the positive fields:
(i.e. The title & description from expression is shown but none of the actual species information)
Here is the expression modified from your example above:
var flds = ['Ochlerotatus_camptorhynchus1','Ochlerotatus_camptorhynchus2','Ochlerotatus_camptorhynchus3','Ochlerotatus_camptorhynchus4','Ochlerotatus_camptorhynchusF','Ochlerotatus_camptorhynchusM','Culex_pervigilans1','Culex_pervigilans2','Culex_pervigilans3','Culex_pervigilans4','Culex_pervigilansF','Culex_pervigilansM','Culex_quinquefasciatus1','Culex_quinquefasciatus2','Culex_quinquefasciatus3','Culex_quinquefasciatus4','Culex_quinquefasciatusF','Culex_quinquefasciatusM','Ochlerotatus_antipodeus1','Ochlerotatus_antipodeus2','Ochlerotatus_antipodeus3','Ochlerotatus_antipodeus4','Ochlerotatus_antipodeusF','Ochlerotatus_antipodeusM','Ochlerotatus_notoscriptus1','Ochlerotatus_notoscriptus2','Ochlerotatus_notoscriptus3','Ochlerotatus_notoscriptus4','Ochlerotatus_notoscriptusF','Ochlerotatus_notoscriptusM','Ochlerotatus_australis1','Ochlerotatus_australis2','Ochlerotatus_australis3','Ochlerotatus_australis4','Ochlerotatus_australisF','Ochlerotatus_australisM','Ochlerotatus_subalbirostris1','Ochlerotatus_subalbirostris2','Ochlerotatus_subalbirostris3','Ochlerotatus_subalbirostris4','Ochlerotatus_subalbirostrisF','Ochlerotatus_subalbirostrisM','Coquillettidia_iracunda1','Coquillettidia_iracunda2','Coquillettidia_iracunda3','Coquillettidia_iracunda4','Coquillettidia_iracundaF','Coquillettidia_iracundaM','Coquillettidia_tenuipalpis1','Coquillettidia_tenuipalpis2','Coquillettidia_tenuipalpis3','Coquillettidia_tenuipalpis4','Coquillettidia_tenuipalpisF','Coquillettidia_tenuipalpisM','Opifex_fuscus1','Opifex_fuscus2','Opifex_fuscus3','Opifex_fuscus4','Opifex_fuscusF','Opifex_fuscusM','Culiseta_novazealandae1','Culiseta_novazealandae2','Culiseta_novazealandae3','Culiseta_novazealandae4','Culiseta_novazealandaeF','Culiseta_novazealandaeM','Culiseta_tonnoiri1','Culiseta_tonnoiri2','Culiseta_tonnoiri3','Culiseta_tonnoiri4','Culiseta_tonnoiriF','Culiseta_tonnoiriM','Maorigoeldia_argyropus1','Maorigoeldia_argyropus2','Maorigoeldia_argyropus3','Maorigoeldia_argyropus4','Maorigoeldia_argyropusF','Maorigoeldia_argyropusM','Culex_asteliae1','Culex_asteliae2','Culex_asteliae3','Culex_asteliae4','Culex_asteliaeF','Culex_asteliaeM','Culex_rotoruae1','Culex_rotoruae2','Culex_rotoruae3','Culex_rotoruae4','Culex_rotoruaeF','Culex_rotoruaeM','Opifex_chathamicus1','Opifex_chathamicus2','Opifex_chathamicus3','Opifex_chathamicus4','Opifex_chathamicusF','Opifex_chathamicusM','Culex_sitiens1','Culex_sitiens2','Culex_sitiens3','Culex_sitiens4','Culex_sitiensF','Culex_sitiensM','Other','Exotic_Species'];
var info = [];
var atts = {};
for (var i in flds) {
var fldname = flds[i];
if (!IsEmpty($feature[fldname])) {
Push (info, {'fieldName': fldname})
atts[fldname] = $feature[fldname];
}
}
return {
type: 'fields',
title: 'Mosquitoes collected',
description : 'Larvae 1-4 (instar) or Adult F/M',
fieldInfos: info,
attributes : atts
}
Do you have any suggestions as to why I can't see the positive values (Species information) from the table?
Thank you!
Jessica
Xander-Can you help me pleas? I'm trying to follow your information in the post and am lost where I actually put the html information and then the Arcade expression. Am I clicking under Options-Attribute expressions and adding it there? Am I clicking Add content and choosing Arcade? I'm working in Portal and trying to configure my popup to remove the fields that don't have a number.
Hi Cowardin,
this is the workflow.
1-in the classic viewer, do the following:
2-select the three dots next to your layer.
3-Configure Pop-up
4- Display: A custom attribute display
5-click Configure (green button)
6-View HTML Source <>
7- paste your html code
8- click ok after your adjustments
9- Click ADD
10- paste your arcade code in here.
11- test it and ok
12- click OK
13-Save
Cheers
P
By the way for the ones asking about different links according to values in a field, have a look at this:
cheers
P
I'm in regular map viewer, not classic. Does it work the same way?
sorry for the late answer.
I have no idea...
I would like to know that, too.
@CJCowardin @PSGeo Here's some code you can just copy and paste in the new map viewer Arcade content block within the popups settings:
// Creates a table with only fields that contain data
Expects($feature, '*');
var fields = Schema($feature).fields;
function getNames(field){
return field.name;
}
function getFieldsMetaData() {
var field_meta = {};
for (var f in fields) {
field_meta[Lower(fields[f].name)] = {
"alias": fields[f].alias,
"domain":HasKey(fields[f],"domain"),
"fieldType": fields[f].type,
"name" : fields[f].name
}
}
return field_meta;
}
function formatField(fieldMetaData) {
//applies some basic formatting for dates and domains
if (fieldMetaData.domain == true) {
return DomainName($feature, fieldMetaData.name)
}
if (fieldMetaData.fieldType == "esriFieldTypeDate") {
return Text($feature[fieldMetaData.name], 'MMM DD YYYY hh:mm')
}
return $feature[fieldMetaData.name]
}
function filterValidFields(fieldName){
// skip some system fields and some other fields that are not needed
var skipNames = [
"objectid",
"fid",
"shape__area",
"shape__length"];
return !includes(skipNames, lower(fieldName)) && !IsEmpty($feature[fieldName]) && !IsNan($feature[fieldName]);
}
var validFields = Filter(Map(fields, getNames), filterValidFields);
var attributes = {};
var fieldInfos = [];
var fieldMetaInfo = getFieldsMetaData();
for (var f in validFields){
var fieldName = validFields[f];
var fieldMeta = fieldMetaInfo[Lower(fieldName)]
var fieldAlias = fieldMeta.alias
Push(fieldInfos, { fieldName: fieldAlias})
attributes[fieldAlias] = formatField(fieldMeta)
}
return {
type: "fields",
fieldInfos: fieldInfos,
attributes: attributes
};
How could this be altered to use a predefined list of attributes, hopefully giving you an option for order?
I tried modifying the Expects function by entering a list of attributes, limiting the number returned, however I continue to receive all attributes (unordered) from the Schema($feature) call.