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:
var attributes = Dictionary($feature)["attributes"];
var fieldInfos = [];
var attributeValues = {};
var excludeFields = ["OBJECTID", "EditDate", "Creator", "GlobalID", "CreationDate", "Editor"];
for (var key in attributes) {
var value = attributes[key];
if (!IsEmpty(value) && value != "" && IndexOf(excludeFields, key) == -1) {
Push(fieldInfos, { fieldName: key });
attributeValues[key] = value;
}
}
return {
type: 'fields',
fieldInfos: fieldInfos,
attributes: attributeValues
};
This had the intended effect of hiding irrelevant and empty fields.
I need to also control the order in which the returned visible fields are displayed. This expression is currently returning the fields in alphabetical order. I need to have the same three fields displayed at the top of the pop up in the following order for every submission: HMA, Observation Date and Time, and Type. I do not care about the order of the other 5-8 fields that would be displayed. Ideally I would like to order the popup in the same display order of the collector forms.
I am not sure how to proceed. I have tried several alternatives and I am not getting the result I intend.