Hi there,
I have fields in my forms that are not relevant/used during every form submission. I would like to exclude empty fields from the popups and always exclude data not relevant to viewer such as OBJECTID, EditDate, Creator, GlobalID, CreationDate, Editor etc.
I found an expression from another community post and input the fields I wanted excluded:
Solved! Go to Solution.
Thanks for pointing that out. I did leave off the Expects function at the top of the code. All you need to do is add this as the first line
Expects($feature, "*");
To maintain the order of the fields, you have to get the schema of the feature. Try this code, which returns the field alias and domain name (if the field has a domain)
var fields = Schema($feature).fields;
var fieldInfos = [];
var attributes = {};
var excludeFields = [
"OBJECTID",
"EditDate",
"Creator",
"GlobalID",
"CreationDate",
"Editor"
];
for (var field of fields) {
var key = field.alias;
var value = DomainName($feature, field.name);
if (!IsEmpty(value) && value != "" && IndexOf(excludeFields, key) == -1) {
Push(fieldInfos, { fieldName: key });
attributes[key] = value;
}
}
return { type: "fields", fieldInfos: fieldInfos, attributes: attributes };
Thank you for your response! I am still new to using Arcade Expressions.
When I first tried the expression the pop up window populates with data. After saving and clicking off the current point to a different point on the same layer all the pop ups are blank. The only way I can get the expression to display anything in the popup window now is to have a field list as well as the arcade expression which is now displaying the block of fields from the arcade expression and the field list in a separate block below. If I remove the field list it returns a blank popup window. I think I am doing something wrong.
Any ideas? When I tried looking for solutions to this blank popup issue it looks like I need to use the Expect function but not sure how I would go about that.
Thanks for pointing that out. I did leave off the Expects function at the top of the code. All you need to do is add this as the first line
Expects($feature, "*");
Thank you so much for the help! Now it is behaving exactly as I had hoped. I don't think I would have thought to add it to the first line. I had tried it at the end of the string. You have been such a great help, I greatly appreciation for your generosity. Hopefully this also aids someone else.