Need optimisation help

Hi there,

I built an automation where I got an input JSON through a webhook that needs to create a deal in pipedrive. I want to use the “true” or “false” values from certain keys to be mapped in a multiselect.
Screenshot 2024-06-11 at 12.34.40
to map in
Screenshot 2024-06-11 at 12.35.51

My automation now looks like this (and it works):

Where the logic is as following:
Receive webhook data
Create empty variable called : Norms
rout and filter to check wether (for instance) ISO 9001 = true and Exists
Get variable value from Norms
Set variable to be : “Norms”&ISO 9001,
Screenshot 2024-06-11 at 12.39.57

After looping through all the options the value can look like:
Screenshot 2024-06-11 at 12.40.41

I then TRIM and SPLIT the value to be an array so it can be fed to the pipedrive module.
As you can imagine, i feel like it can be done easier and more smooth. Especially because the client has several multiselect fields they want to have and the norms i used to build the automation was just a handfull of the dozens.

Is there an array agregator or something that could work here?

Cheers, a fellow builder

Welcome to the Make community!

I don’t want to assume the raw keys of the collection, so could you please provide the output bundle?

Please provide the output bundles of the modules by running the scenario, then click the white speech bubble on the top-right of each module and select “Download output bundles”.
Screenshot_2023-10-06_141025

A.

Save the bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading it here will look like this:

bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted output bundle in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

samliewrequest private consultation

Join the unofficial Make Discord server to chat with us!

1 Like

Do you need all of the different modules output? Or just the original webhook output?

output webhook.txt (1.0 KB)

Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of one module:

Output:

Screenshot_2024-06-11_190640

Give it a go and let us know if you have any issues!

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.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 86,
                    "module": "json:ParseJSON",
                    "version": 1,
                    "parameters": {
                        "type": ""
                    },
                    "mapper": {
                        "json": "[\n    {\n        \"name\": \"Offerteaanvraag | Guardey\",\n        \"site\": \"654385bc2a9744da05684b9e\",\n        \"data\": {\n            \"Bedrijfsnaam\": \"Workflow heroes\",\n            \"Voornaam\": \"Marc\",\n            \"Achternaam\": \"van workflowheroes\",\n            \"Email\": \"marc@workflowheroes.nl\",\n            \"Telefoon\": \"0626271596\",\n            \"ISO 9001\": \"false\",\n            \"ISO 27001\": \"true\",\n            \"NEN 7510\": \"false\",\n            \"ISAE 3402\": \"true\",\n            \"SOC 2\": \"false\",\n            \"Andere norm\": \"\",\n            \"Guardey 3\": \"true\",\n            \"Fysieke Training 3\": \"true\",\n            \"Aantal Gebruikers\": \"200000\",\n            \"Onboarding voor admins\": \"true\",\n            \"LMS Adviesrapport\": \"true\",\n            \"Maatwerktraining\": \"true\",\n            \"Pagina\": \"https://www.kamcertificeringen.nl/guardey\",\n            \"Dienst\": \"Security Awareness Game\"\n        },\n        \"d\": \"2024-06-07T10:17:40.773Z\",\n        \"_id\": \"6662de449c5f94951440bee3\",\n        \"formId\": \"6548e1ecb20121e66f0ddf67\"\n    }\n]"
                    },
                    "metadata": {
                        "designer": {
                            "x": -98,
                            "y": -1561
                        },
                        "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
                            }
                        ]
                    }
                },
                {
                    "id": 88,
                    "module": "util:SetVariable2",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "name": "array",
                        "scope": "roundtrip",
                        "value": "{{slice(deduplicate(add(emptyarray; null; if(86.data.`ISO 9001` = \"true\"; \"ISO 9001\"; null); if(86.data.`ISO 27001` = \"true\"; \"ISO 27001\"; null); if(86.data.`NEN 7510` = \"true\"; \"NEN 7510\"; null); if(86.data.`ISAE 3402` = \"true\"; \"ISAE 3402\"; null); if(86.data.`SOC 2` = \"true\"; \"SOC 2\"; null))); 1)}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 80,
                            "y": -1560
                        },
                        "restore": {
                            "expect": {
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "interface": [
                            {
                                "name": "array",
                                "label": "array",
                                "type": "any"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

2 Likes

Thank you kindly good sir. The Slice feature is going to be a lifesaver! Definatly got what i came for to optimise it :slight_smile:

2 Likes

The trick is avoid using routers, and abuse use the built-in functions.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

2 Likes

Feel free when you have some time to check out the Make for Make Newbies video series which includes a run through of ALL the array functions – including slice(). There is a lot to (ab)use there no doubt! :slight_smile:

@samliew very clever use to add the initial {{null}} to the add() function for the edge case where all of the cases are true and you still want to slice starting with the second element of the array.

slice() is odd because the first element of an array is set to 0 rather than 1, so 1 is actually used to extract the array elements starting with the second element.

1 Like