Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8.5.0 Select All - Bulk Export fails on Accts, Contacts & Products with ‘Unexpected Error when calling action’ message #442

Open
ggraynoth opened this issue Feb 28, 2024 · 4 comments · May be fixed by #461
Labels
Area: Listview Issues & PRs related to all things regarding the Listview Priority:Important Issues & PRs that are important; broken functions; errors; there are workarounds Severity: Moderate Minor Impact Type: Bug Something isn't working

Comments

@ggraynoth
Copy link

ggraynoth commented Feb 28, 2024

In Accounts, Contacts and Products (may also be an issue in other modules but not tested), when you click on the Select check box, in the list view and select all records and then go into Bulk Action and try to export the records, the system error with an Unexpected Error when calling action’ message. This prevents export of the full database for that module.

Issue

You should be able to select all and export without any failure. This fails regardless of database size (no. of records) and is a bug, as this should work.

Expected Behavior

Select all records and Bulk action Export should produce the Excel CSV export file of the database selected.

Actual Behavior

The system displays the error as defined above and aborts the export. No file is created.

Possible Fix

As a work around, which exemplifies why this is a bug when taking the 'select all' path, is to filter the database and then do the same thing on the filtered selection. This then works. So, as a workaround, we have created a bogus 'type ' field
in the case of Accounts and similar for contacts and products, then created an account with a type equal to the bogus value. This can be used within the filter function. We then filter by selecting all Account types except for the bogus value in the drop down and create a filter, which is effectively all records except for the one with the bogus type.

Then select all and bulk export and it works fine.

Which would indicate that there is a code path which is failing, when all records with no filter is attempted.

Steps to Reproduce

Go into the accounts module, select all records in the list view and then try to do a bulk action, Export. This will fail as per the above.

Redo using the filter method highlighted above and it will work.

Context

As we had a fault with the bounceback feature, which meant it was not working, no contacts were tagged as bounced invalid or bounced other. We have now fixed this. however, whilst this was happening, we needed to export the contact database and match the bounced contacts and reimport, which we couldn't do by selecting and exporting all contact records. We had to find the filter work-around and do it that way.

These features should work as they absorb a lot of time to identify the work-around, however the bug still persists. There are also reports in the Forum that other functions fail, where Select All does not work for bulk actions for no apparent reason. These may be linked but we have not had reason to use these functions.

Your Environment

SuiteCRM 8.5.0
MariaDB 10.5.22
PHP 8.1.26

@johnM2401 johnM2401 added Type: Bug Something isn't working Priority:Important Issues & PRs that are important; broken functions; errors; there are workarounds Area: Listview Issues & PRs related to all things regarding the Listview Severity: Moderate Minor Impact labels Feb 28, 2024
@rsteinig
Copy link

rsteinig commented Feb 28, 2024

Local project overwrite of the two affected functions done by me of wrong "CsvExportBulkAction.php" file fixed that issue for me. Somehow the request does ignore the "all" use-case. Would be better, to send a valid "all" param instead of guessing it before an exception is thrown.

/**
* @inheritdoc
*/
public function validate(Process $process): void
{
if (empty($process->getOptions())) {
throw new InvalidArgumentException(self::MSG_OPTIONS_NOT_FOUND);
}

    $options = $process->getOptions();

    if (empty($options['module']) || empty($options['action'])) {
        throw new InvalidArgumentException(self::MSG_OPTIONS_NOT_FOUND);
    }

    if (empty($options['fields'])) {
        throw new InvalidArgumentException(self::MSG_OPTIONS_NOT_FOUND);
    }

    $all = empty($options['ids']) && is_array($options['criteria']) && !empty($options['fields']);
    if (!$all && empty($options['ids']) && empty($options['criteria'])) {
        throw new InvalidArgumentException(self::MSG_OPTIONS_NOT_FOUND);
    } else {
        $options['all'] = $all;
        $process->setOptions($options);
    }
}

/**
* @param array|null $options
* @return array
*/
protected function getDownloadData(?array $options): array
{
$responseData = [
'handler' => 'export',
'params' => [
'url' => 'legacy/index.php?entryPoint=export',
'formData' => []
]
];

    if (!empty($options['ids']) || !empty($options['all'])) {
        $responseData = $this->getIdBasedRequestData($options, $responseData);

        return $responseData;
    }

    if (!empty($options['criteria'])) {
        $responseData = $this->getCriteriaBasedRequestData($options, $responseData);
    }

    return $responseData;
}

@ggraynoth
Copy link
Author

Thank you.

However did not work for our back-up or prod installations.

We did the code update exactly as defined and saved the CsvExportBulkAction.php after having taken a back-up. Then double checked that the new code was in place.

Cleared the browser cache and logged back in to SuiteCRM - same result - 'Unexpected Error when calling action' when trying to export all contacts or accounts.

Thanks anyway - hope this helped someone. The code does look sound, although I am no expert.

@rsteinig
Copy link

rsteinig commented Mar 1, 2024

Ok, I am sorry, it didn't work out for you, Just tried again on my local instance by just swapping the files and it run... Maybe you can use some local Xdebug session and check out, if the "validate" method gets executed or not. Good luck.

@ggraynoth
Copy link
Author

ggraynoth commented Mar 1, 2024 via email

jack7anderson7 added a commit to jack7anderson7/SuiteCRM-Core that referenced this issue Apr 12, 2024
jack7anderson7 added a commit to jack7anderson7/SuiteCRM-Core that referenced this issue Apr 12, 2024
@jack7anderson7 jack7anderson7 linked a pull request Apr 16, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Listview Issues & PRs related to all things regarding the Listview Priority:Important Issues & PRs that are important; broken functions; errors; there are workarounds Severity: Moderate Minor Impact Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants