Select to view content in your preferred language

FormTemplate ExpressionInfos not working

263
1
11-11-2023 05:46 AM
JanHellenberg
New Contributor II

I am using FormTemplate in a FeatureForm to show elements from a Featurelayer, which works fine. But when I try to replace the field with a calculated expression using the FormTemplates ExpressionInfos, nothing happens and the value from the Featurelayer field is still showing. I have tried with 4.27 and 4.28 and I get no errors in console.

const featureForm = new FeatureForm({
view: view,
layer: MyLayer,
feature: view.popup.selectedFeature,
formTemplate: {
expressionInfos: [
  { 
  name: 'Test',
  title: 'Test'
  expression: '$feature.Field2',
  returnType: 'string',
  },],

elements: [
  new FieldElement({
  type: 'field',
  fieldName: 'Field1',
  label: 'Label: ',
  valueExpression: 'Test',
}),],},})

 

So, in this simplified example I would like to display the Field2 value (as calculated in the expression) instead of Field1 but Field1 is still displayed. Of course, my plan is to perform a more complex expression once I get this to work. Can someone help?

0 Kudos
1 Reply
ThomasHarner1
Esri Contributor

Hi Jan, 

From what I understand it appears that a Field Element in a Form is pretty strict about the schema/rules of the underlying table/servcie endpoint, and cannot return a value from an ExpressionInfo unless that targeted field is set to not be editable.

Try and add the line "editableExpression: 'return false'" below the valueExpression parameter and see if the value shows up then. I think the idea with valueExpressions is that they dynamically calculate other fields based on another and are not intended to be directly modified by a user. 
 
Thomas
 
0 Kudos