How do I assign values to a field whose name is dynamic?
Eugene Katz
Posts: 51 ✭✭
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
0
Best Answer
-
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 columnYou'd end up with this:
Object.assign(__e, {[__e["fieldName"]]: "bar"})
1
Answers
-
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 columnYou'd end up with this:
Object.assign(__e, {[__e["fieldName"]]: "bar"})
1