Select to view content in your preferred language

Maintain Editable Fields While Using Calculated Expressions in Field Maps

152
1
a week ago
Status: Open
Labels (1)
kyankraehenbuehllaixoversumchK
Emerging Contributor

In the previous Field Maps version (25.1.0), I discovered a method that allowed me to calculate attributes while still keeping the fields editable. By combining both a Calculate Expression and an Editing Expression for the same field, I was able to bypass the limitation that calculated fields become locked and cannot be edited at certain points in the workflow.

 

Below is an example of how this worked:

 

  1. Field: “Bestand Werte kopieren” (Copy Existing Values)

Editing Expression:

if (IsEmpty($feature.BAUWERK_REF) || $feature.BESTAND_WERTE_KOPIEREN == 1) {

   return false

} else {

   var relatedFeatures = FeatureSetByRelationshipName(

      $feature,

      "ABWASSER_MASTER_OWNER.ABW_BESTAND_BAUWERK",

      ['BEZEICHNUNG']

   );

   var firstFeature = First(relatedFeatures);

   return (

      $feature.BEZEICHNUNG != firstFeature.BEZEICHNUNG

   );

}

 

Calculated Expression:

return 2

 

  1. Field: “Bezeichnung” (Label/Name)

Calculated Expression:

if (IsEmpty($feature.BAUWERK_REF)) {

   return $feature.BEZEICHNUNG

} else {

   var relatedFeatures = FeatureSetByRelationshipName(

      $feature,

      "ABWASSER_MASTER_OWNER.ABW_BESTAND_BAUWERK",

      ['BEZEICHNUNG']

   );

   var firstFeature = First(relatedFeatures);

   return firstFeature.BEZEICHNUNG;

}

 

Editing Expression:

DomainName($feature, "BESTAND_WERTE_KOPIEREN") == "Werte aus Bestand kopieren"

 

Why This Workflow Was Necessary (and Worked in the Old Version)

 

The purpose of these expressions was to temporarily trigger the recalculation of the Bezeichnung field when the user switched the value of Bestand Werte kopieren to 1. The calculated expression filled the field with the related feature’s value. Then, by returning 2, the field switched back to an editable state, allowing the user to adjust the values as needed while still having the ability to restore the copied values at any time.

 

Question for the New Version of Field Maps

 

In the new Field Maps version, this workaround no longer functions as it did before.

 

Is there a new or recommended approach that allows fields to be calculated while still remaining editable afterwards?

 

Any guidance, best practices, or alternative workflows would be greatly appreciated.

1 Comment
RPGIS
by MVP Regular Contributor

Hi @kyankraehenbuehllaixoversumchK,

First, please use the code function when pasting any type of code, otherwise it makes it difficult to troubleshoot your issue.

//Field: “Bestand Werte kopieren” (Copy Existing Values)
//Editing Expression:

if (IsEmpty($feature.BAUWERK_REF) || $feature.BESTAND_WERTE_KOPIEREN == 1) {
   return false
} else {
   var relatedFeatures = FeatureSetByRelationshipName(
      $feature,
      "ABWASSER_MASTER_OWNER.ABW_BESTAND_BAUWERK",
      ['BEZEICHNUNG']
   );
   var firstFeature = First(relatedFeatures);
   return (
      $feature.BEZEICHNUNG != firstFeature.BEZEICHNUNG
   );
}
//Calculated Expression:
return 2

//Field: “Bezeichnung” (Label/Name)
//Calculated Expression:
if (IsEmpty($feature.BAUWERK_REF)) {
   return $feature.BEZEICHNUNG
} else {
   var relatedFeatures = FeatureSetByRelationshipName(
      $feature,
      "ABWASSER_MASTER_OWNER.ABW_BESTAND_BAUWERK",
      ['BEZEICHNUNG']
   )
   var firstFeature = First(relatedFeatures)
   return firstFeature.BEZEICHNUNG
}

//Editing Expression:
//DomainName($feature, "BESTAND_WERTE_KOPIEREN") == "Werte aus Bestand kopieren"

 

Secondly, are these calculations used in the same field calculation or are these two different fields with similar calculations. Depending on which then here is perhaps a better approach. Assuming these are the same field.