Is there a good example of how I can dynamically create new payload objects within a function node?
for example:
payload.data.value1  (is a numeric value:  10)
payload.data.value2  (is a string : ‘abc’)
I would like a new payload object where the name is a combination of the 2.
i.e : name is  payload.data.abc and the value is 10
             
            
              
              
              
            
            
           
          
            
            
              To confirm, your incoming payload is …
{
  "payload": {
    "data": {
      "value1": 10,
      "value2": "abc"
    }
  }
}
… and your desired payload is …
{
  "payload": {
    "data": {
      "value1": 10,
      "value2": "abc",
      "abc": 10 // key matches the value of value2, value matches the value of value1
    }
  }
}
This is a straightforward assignment operation in JavaScript using bracket notation, which allows for reading and writing properties with either names that aren’t valid in dot notation or names referenced as variables …
payload.data[payload.data.value2] = payload.data.value1;
             
            
              
              
              
            
            
           
          
            
            
              ok, thanks. Can this be used in a Mutate node as well?
             
            
              
              
              
            
            
           
          
            
            
              It’s actually not possible to do in a Mutate Node, as we do not have any mechanism for dynamically setting a payload path for the destination of the new value.
But that question has come up before and I’ll +1 the feature request.