Make a field optional or ignore if empty so that the operation can proceed

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.

Did you try omit ?

2 Likes

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

Screenshot_2024-04-26_220408

3. Output

Screenshot_2024-04-26_220418

URL empty example

1. Example data

3. Output

Screenshot_2024-04-26_220446

4.

Map this logo_array variable into your Logo field

de356cbba1d07238135d95d334c0451bd4f5c873

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. 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