Choose the right Contact

Hi together, in this case, i am searching for contacts that are asigned to a deal. I have to choose the one, that has not the “unterstützer” label. How can i do this?

Everytime you see an “array”, think of the map function.

You can use the built-in function map

e.g.:

{{ map(1.Associations.Contacts; associated_object_id; type; deal_to_contact) }}

The above is just an example. You need to use the raw key names, which can be found by mouse-over the labels, or when you export the output bundle of the module.

For more information, see

If you need further assistance, please provide the following:

Please provide the output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

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

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles 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 input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

This will allow others to better assist you. Thanks!

3 Likes

here is the output. I need to have the one, that is not “unterstützer”. My problem is, that it is two times in there

[
    {
        "id": 10624214730,
        "associations": {
            "contacts": [
                {
                    "id": "4356251",
                    "type": "deal_to_contact"
                },
                {
                    "id": "4400501",
                    "type": "deal_to_contact"
                },
                {
                    "id": "4356251",
                    "type": "unterstützer"
                }
            ]
        },
        "__IMTLENGTH__": 1,
        "__IMTINDEX__": 1
    }
]

So do you want the first one “4356251” or the second one “4400501”? or both, but individually?

2 Likes

in this case i want to have the second one, case the first one is the “unterstützer”.

Now I’m confused, because the first one is “deal_to_contact” and not “unterstützer”.

Screenshot_2024-02-23_220226

Anyway you can use this to get the first id

{{ get(map(1.associations.contacts; id; type; deal_to_contact); 1) }}

and this to get the second id

{{ get(map(1.associations.contacts; id; type; deal_to_contact); 2) }}

Alternatively, you can put the “Contacts” array into an Iterator module,

then add a filter after the module to accept the contact if the type is not “unterstützer”.

2 Likes

the problem the first one and the third is the same. The deal has 2 contacts associated. One has the label “unterstützer” and the otherone has no label. And i need to have the one without a label.
Thats why its tricky.

Oh goodness! I’m so sorry that I didn’t realise the first and third had the same IDs!

You’ll need a minimum of three modules:

1. Iterate contacts array

Screenshot_2024-02-23_230254

2. Array aggregate (group by id)

3. Filter: Accept only if does not contain “unterstützer”

4. Reference key from aggregator to get contact ID

Output

Screenshot_2024-02-23_230233

Give it a go and let us know if you have any issues! (copy modules from below)

2 Likes

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

  1. Copy the 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 to paste in the canvas.

  3. Click on each imported module and save it. You may need to remap some variables.

Modules JSON Export

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 152,
                    "module": "builtin:BasicFeeder",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "array": "{{151.associations.contacts}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 73,
                            "y": -3752
                        },
                        "restore": {
                            "expect": {
                                "array": {
                                    "mode": "edit"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "array",
                                "type": "array",
                                "label": "Array",
                                "mode": "edit",
                                "spec": []
                            }
                        ]
                    }
                },
                {
                    "id": 153,
                    "module": "builtin:BasicAggregator",
                    "version": 1,
                    "parameters": {
                        "feeder": 152
                    },
                    "mapper": {
                        "id": "{{152.id}}",
                        "type": "{{152.type}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 318,
                            "y": -3751
                        },
                        "restore": {
                            "extra": {
                                "feeder": {
                                    "label": "Iterator [152]"
                                },
                                "target": {
                                    "label": "Custom"
                                }
                            }
                        },
                        "advanced": true
                    },
                    "flags": {
                        "groupBy": "{{152.id}}",
                        "stopIfEmpty": true
                    }
                },
                {
                    "id": 156,
                    "module": "util:SetVariable2",
                    "version": 1,
                    "parameters": {},
                    "filter": {
                        "name": "not unterstützer",
                        "conditions": [
                            [
                                {
                                    "a": "{{map(153.array; \"type\"; \"type\"; \"unterstützer\")}}",
                                    "o": "array:equal",
                                    "b": "0"
                                }
                            ]
                        ]
                    },
                    "mapper": {
                        "name": "contact",
                        "scope": "roundtrip",
                        "value": "{{153.`__IMTKEY__`}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 665,
                            "y": -3753
                        },
                        "restore": {
                            "expect": {
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "name",
                                "label": "Variable name",
                                "type": "text",
                                "required": true
                            },
                            {
                                "name": "scope",
                                "label": "Variable lifetime",
                                "type": "select",
                                "required": true,
                                "default": "roundtrip",
                                "options": [
                                    {
                                        "label": "One cycle",
                                        "value": "roundtrip"
                                    },
                                    {
                                        "label": "One execution",
                                        "value": "execution"
                                    }
                                ]
                            },
                            {
                                "name": "value",
                                "label": "Variable value",
                                "type": "any"
                            }
                        ],
                        "interface": [
                            {
                                "name": "contact",
                                "label": "contact",
                                "type": "any"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}
2 Likes

its working perfect… thanks a lot

3 Likes