Hey everyone,
Is there a way to make a field optional in a bundle?
I am looking to send over a bunch of info from one Notion database to another. The problem is that there is one data point (practically two) that is sometimes included while other times not.
I tried to use ifempty
function and ignore
keyword. But that didn’t seem to have done the trick.
The other option that I thought of, is to build two branches and direct them to the right one based on whether the data point(s) is included or not.
Thanks for the quick reply, @samliew
Don’t think I exactly understood where or how you’d like me to use omit
, tried couple of variations of this but still get the error.
Hmm, the logo field expects an array of logo collections (objects).
In that case you might want to do something like this:
1. Example data (from your module 2)
2. Parse JSON module
3. Output
URL empty example
1. Example data
3. Output
4.
Map this logo_array
variable into your Logo field
Module Export
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
-
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
-
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
JSON
{
"subflows": [
{
"flow": [
{
"id": 81,
"module": "json:ParseJSON",
"version": 1,
"parameters": {
"type": ""
},
"mapper": {
"json": "{\n \"logo_array\": [\n {{if(length(80.URL) != 0; \"{\n \"\"url\"\": \"\"\" + 80.URL + \"\"\",\n \"\"name\"\": \"\"\" + 80.Name + \"\"\"\n }\"; emptystring)}}\n ]\n}"
},
"metadata": {
"designer": {
"x": -692,
"y": -2665
},
"restore": {
"parameters": {
"type": {
"label": "Choose a data structure"
}
}
},
"parameters": [
{
"name": "type",
"type": "udt",
"label": "Data structure"
}
],
"expect": [
{
"name": "json",
"type": "text",
"label": "JSON string",
"required": true
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}
1 Like