# Salesforce Integration Campaign Members filter not working after upgrade to Mautic 3

**URL:** <https://forum.mautic.org/t/salesforce-integration-campaign-members-filter-not-working-after-upgrade-to-mautic-3/19185>\
**Category:** Mautic 3 - Install/Upgrade Support\
**Created:** [April 26, 2021, 9:14am UTC](https://forum.mautic.org/t/salesforce-integration-campaign-members-filter-not-working-after-upgrade-to-mautic-3/19185 "2021-04-26T09:14:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewday](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/matthewday/32/433_2.png) [@matthewday](https://forum.mautic.org/u/matthewday)\
**Post date:** [April 26, 2021, 9:14am UTC](https://forum.mautic.org/t/salesforce-integration-campaign-members-filter-not-working-after-upgrade-to-mautic-3/19185/1 "2021-04-26T09:14:11Z")

</div>

**Your software**  
_My PHP version is_ : 7.3.17  
_My MySQL/MariaDB version is_ (delete as applicable): 5.7.28

**Updating/Installing Errors**  
_I am_ (delete as applicable): Updating  
_Upgrading/installing via_ (delete as applicable) : Web AND Command Line

_These errors are showing in the installer_ :

_These errors are showing in the Mautic log_ :

Too many characters to post here (100k characters), but this error gets registered when I try to make changes to the segment integration campaign members:  
mautic.WARNING: PHP Warning - array\_flip(): Can only flip STRING and INTEGER values! - in file /var/www/vhosts//app/bundles/LeadBundle/Form/Type/FilterTrait.php - at line 275

_These errors are showing in the upgrade\_log.txt file (located in the root of your Mautic instance when an upgrade has been attempted - ensure you remove or redact any sensitive data such as domain names in the file path)_ :

**Your problem**  
_My problem is_ : I have upgraded from v2.16.5 to v.3.3.2 via v3.2.4. I had a couple of issues with the upgrade process - particularly hitting the ERR\_MAUTIC\_3\_MIGRATIONS\_IDENTIFICATION\_FAILED error - which I resolved by manually running php bin/console doctrine:migrations:migrate

Our Mautic is connected to our salesforce instance and relies upon Salesforce Campaign Membership for building segments. Following the upgrade from v2.16.5 to v3.2.4, the Integration Campaign Members picklists on existing Segments are empty.

I reauthorized the Salesforce connector and re-ran synccontacts --integration=Salesforce but the Campaigns did not appear in the Integration Campaign Members picklists.

Knowing that v3.2.4 is not the latest release, I performed a command line upgrade to v3.3.2 – successfully applying the upgrade and schema updates. I then attempted a reauthorization of the plugin and a synccontacts again but no difference - the Integration Campaign Members picklist is still blank.

If I _remove_ the existing Integration Campaign Members picklist from the Segment filters and then _add_ a new Integration Campaign Members picklist, the list of Salesforce Campaigns appears in the picklist. However, if I attempt to save the Segment filters having selected a value in the picklist, I get the following error: **This value is not valid.**

If I run php bin/console doctrine:migrations:migrate, I get a WARNING! You have 134 previously executed migrations in the database that are not registered migrations. Other than that the results are No migrations to execute.

From the log file, it looks like something is unhappy, but I’m not sure exactly what!

Any help would be much appreciated…

Thanks!

---

<div class="post-metadata">

**Author:** ![bas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bas/32/547_2.png) [@bas](https://forum.mautic.org/u/bas)\
**Post date:** [May 29, 2021, 7:46pm UTC](https://forum.mautic.org/t/salesforce-integration-campaign-members-filter-not-working-after-upgrade-to-mautic-3/19185/2 "2021-05-29T19:46:03Z")

</div>

We have several clients who experience the same issue. After some more digging I found out that it had nothing to do with migrations of the database. The problem has to do with some code changes from 2 to 3. Even with a clean install you cannot create a valid “Integration Campaign Members” filter for segments.

Luckily I found a quick fix that will make it work for our clients (fix will follow below), but this limits the functionality of this field. But since PHP and Symfony are not my strong suits I’m still looking for a complete fix. The problem has to do with the way, the optionlist is built. The fact that they are categorized seems to be the problem, I don’t think the form builder can handle this.

To fix this issue, you can remove the categorization. But this would make selecting the right campaign more difficult when there are more categories than Salesforce (in the code, a comment says that that is possible since 2.11.0). I still have to find a scenario where there are more categories than Salesforce, and the only scenario I could find are Marketing groups within ConnectWise (?).

To fix this issue, you only have to change one line of code. In the the CRM bundle LeadListSubscriber (`plugins/MauticCrmBundle/EventListener/LeadListSubscriber.php`), just change line 84 from

```php
$choices[$integration->getDisplayName()] = $integrationChoices;

```

to

```php
$choices = array_merge($choices, $integrationChoices);

```

This should fix the issue, but if you have a SF connection and a ConnectWise connection, this might make it difficult to see which is which. To fix this, you can add the following code just above line 84:

```php
array_walk(
    $integrationChoices,
    function (&$choice) use ($integrationName) {
        $choice['label'] = $integrationName . ': ' . $choice['label'];
    }
);

```

This code will prefix the labels with the integration name, so that you can recognize them beter.

I’ll keep looking for a solution/fix for the issue with displaying the categories, but I’m not sure how long it’ll take.

For good measure, the function should look like this:

```php
public function onFilterChoiceFieldsGenerate(LeadListFiltersChoicesEvent $event)
{
    $services = $this->helper->getIntegrationObjects();
    $choices = [];

    /** @var CrmAbstractIntegration $integration */
    foreach ($services as $integration) {
        if (!$integration || !$integration->getIntegrationSettings()->isPublished()) {
            continue;
        }

        if (method_exists($integration, 'getCampaigns')) {
            $integrationChoices = $integration->getCampaignChoices();
            if ($integrationChoices) {
                $integrationName = $integration->getName();
                // Keep BC with pre-2.11.0 that only supported SF campaigns
                if ('Salesforce' !== $integrationName) {
                    array_walk(
                        $integrationChoices,
                        function (&$choice) use ($integrationName) {
                            $choice['value'] = $integrationName . '::' . $choice['value'];
                        }
                    );
                }

                array_walk(
                    $integrationChoices,
                    function (&$choice) use ($integrationName) {
                        $choice['label'] = $integrationName . ': ' . $choice['label'];
                    }
                );

                $choices = array_merge($choices, $integrationChoices);
            }
        }
    }

    if (!empty($choices)) {
        $config = [
            'label' => $this->translator->trans('mautic.plugin.integration.campaign_members'),
            'properties' => ['type' => 'select', 'list' => $choices],
            'operators' => $this->listModel->getOperatorsForFieldType(
                [
                    'include' => [
                        '=',
                    ],
                ]
            ),
            'object' => 'lead',
        ];
        $event->addChoice('lead', 'integration_campaigns', $config);
    }
}

```

---

<div class="post-metadata">

**Author:** ![morten](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/morten/32/6618_2.png) [@morten](https://forum.mautic.org/u/morten)\
**Post date:** [January 7, 2022, 10:00am UTC](https://forum.mautic.org/t/salesforce-integration-campaign-members-filter-not-working-after-upgrade-to-mautic-3/19185/3 "2022-01-07T10:00:40Z")

</div>

> [@bas](#):
>
> ```auto
> $choices = array_merge($choices, $integrationChoices);
> 
> ```

This problem still persists in Mautic 4.1.1 - and the solution posted here still fixes it…  
THANKS bas ! 🙂
