Creating numeric values from selected criteria

Hi there everyone. I am working with a software application that allows for automation of various tasks. When the selection tool isn’t enough, they allow for Json to be used.

I have a field of available selection. Multiple options could be selected. These selections will be uses to help ID a numeric priority. The more options selected, the higher the value. I would like to update one field with the selections made in the other. The filed name with the selections is below, along with the values I would like to assign for each. The goal would be to get back the total value and please it into the second field.

customfield_13537 could have none or any combination of the following selected.
“Landing the plane” value = 10 points
“Top Customer” value = 5 points
“Cost Savings” value = 10 points.

customfield_13538 is the numeric value. If the first two in the list above were selected, the value would be 15 points for this field.

I will confess, I know nothing about Json, or if this is even possible. Looking for your guidance and knowledge. Thanks in adavance!

Hi @Nywi6100,

There are two basic approaches which can be used whenever you want to update a field depending on another field.

  • Register a custom control for the inputs which correspond to the values, in your case for the multi-selection. Then whenever the value of the multi select changes, you also update the sum property
  • Listen to the data changes of the multi select outside of JSON Forms and modify the data to include the correct sum before handing the data back to JSON Forms

In your case the sum value seems to be read only. So in case the sum value is only needed for the UI but does not need to be actually contained in the data, you could go with with an additional renderer which just listens to the multi-select values and then calculates the sum.

See here for a previous discussion on this topic for a similar use case.