Question

Setting a default value in a dynamic field when dict is true

  • 28 February 2023
  • 1 reply
  • 87 views

I’m trying to set a default value to a dynamic field where dict is true. This would be the example FieldSchema: 

key: “attributes”,

dict: true,

default: {“Points”: “42”}

However, the default value type is string so the default gets set incorrectly where the keys become string indices and the values are the values at a given stringified JSON index. 

Is it possible to set a default key-values to a dict field?


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 4
Badge +9

Hey @kevin-underdog-protocol 👋

dynamic and dict are mutually exclusive - so you wouldn’t be able to use both those properties: https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#fieldschema 

Regardless, since the default property expects a string, I wouldn’t expect you to be able to set a default key-value pair by inserting the object like that 🤔

I’m not sure if it helps, but I found this similar question where the suggestion was to set default to the output of a function that makes an API call and returns the topmost item for example. If you give that a try and have success, let the Community know!