Adding a nested custom attribute for Braze through...
# support
b
Adding a nested custom attribute for Braze through Transformations Hi, we have an immutable payload which we would like to transform and send to Braze to create a nested custom property. However, the original payload does not contain any traits, and we would copy them from properties onto the required traits. The challenge is to create the JSON schema in the payload that would then allow us to create the key / value pairs there. We would need to create a schema like this:
Copy code
"traits": {
    "cars": {
      "update": [{
        "age": 27,
        "id": 1,
        "name": "Alex Keener"
      }],
Is there any JS operation so we can create this schema easily if it did not exist in the original payload?
m
Hey There! 👋 Your message has been received by the RudderStack team. We will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
Do you mean you want to add this property. In the transformation, you can do something like this. I am not sure if this is what you are asking for?
Copy code
if !(event.context?.traits?.cars? && event.context?.traits?.cars?.update?) {
Copy code
// Add the traits object
Copy code
}
b
Thanks @shy-kite-21035, I understand the logic. The challenge is not to construct the if statement but to add the nesting to the event. How would you add the object (with the correct JSON formatting)?
m
Can you share a sample of the payload with the properties and how the object should look in the traits. Also I need to check how the traits object is passed to the destination which is a bit of a trail and error.