Skip to main content
Solved

How do I assign values to a field whose name is dynamic?

  • March 11, 2025
  • 0 replies
  • 19 views

Eugene Katz

I'm trying to assign a value to a field whose name is a value of another field. I expected __e[fieldName] to work, but it doesn't seem to. I get foo2 , but not foo1

361_a6c51a9b0431417e95fb30089de2094f.png

Best answer by Brendan Dalpe

Hey @Eugene Katz , you'll need to use the JavaScript Object.assign operator here in order to set the field name. Because of the dynamic nature of the field name value, it can't be created using the name field column

You'd end up with this:

Object.assign(__e, {[__e["fieldName"]]: "bar"})
361_a76000443664445a98f4f42a519891b1.png361_fec9429724fa48df94e9a679d320ccff.png

  • Inspiring
  • Answer
  • March 11, 2025

Hey @Eugene Katz , you'll need to use the JavaScript Object.assign operator here in order to set the field name. Because of the dynamic nature of the field name value, it can't be created using the name field column

You'd end up with this:

Object.assign(__e, {[__e["fieldName"]]: "bar"})
361_a76000443664445a98f4f42a519891b1.png361_fec9429724fa48df94e9a679d320ccff.png