Clone of Mass Update button in SuiteCRM 8

I want to send “mass email” from the contact list view. I want to add a new button “Send Mass Email”.

When the CRM user clicks on “Send Mass Email” it opens the popup and selects the email template, the user signature. When the user clicks on the “Send Email” button and sends an email to all selected records from the list view.

It is working in Suite 7. How can I add in Suite 8?

Thanks
Asif Khalyani

Hi @offshoreevolution,

It would be hard for our members to point you in the right direction without a direct issue to go off. The following questions may help to narrow our target down a little;

  • Have you attempted to make it work in Suite8?
  • Do you want to go full Suite8 rewriting the implementation or integrate the Suite7 code with as few changes as possible?
  • Have you taken a look at our Suite8 development guide on the docs site?

Thanks for the additional info!

Hi @Mac-Rae

Yes, I am learning Suite8. I am trying to add the “Send Mass Email” button in the list view.
public/legacy/modules/Contacts/metadata/listviewdefs.php

'print-as-pdf' => [
                    'key' => 'print-as-pdf',
                    'labelKey' => 'LBL_PRINT_AS_PDF',
                    'modes' => ['list'],
                    'acl' => ['view'],
                    'aclModule' => 'AOS_PDF_Templates',
                    'params' => [
                        'selectModal' => [
                            'module' => 'AOS_PDF_Templates'
                        ],
                        'allowAll' => false,
                        'max' => 50
                    ]
                ],
                'send-mass-email' => [
                    'key' => 'send-mass-email',
                    'labelKey' => 'LBL_SEND_MASS_EMAIL',
                    'modes' => ['list'],
                    'acl' => ['view'],
                    'aclModule' => 'AOS_PDF_Templates',
                    'params' => [
                        'selectModal' => [
                            'module' => 'AOS_PDF_Templates'
                        ],
                        'allowAll' => false,
                        'max' => 50
                    ]
                ]

Now, I want to custom popup window instead of “AOS PDF Template” record list.

Yes, I want to rewrite the new code for Suite8. But any quick solutions for existing Suite7 existing code some changes. Later on, we will write fresh and new code for Suite8.

I read the Mass Update Bulk action code and clone the file. I do not have an idea how can I call this bulk action file?
core/backend/Process/Service/BulkActions/MassUpdateBulkAction.php clone the file and rename core/backend/Process/Service/BulkActions/SendMassEmailBulkAction.php

<?php
namespace App\Process\Service\BulkActions;

use ApiPlatform\Core\Exception\InvalidArgumentException;
use App\Process\Entity\Process;
use App\Module\Service\ModuleNameMapperInterface;
use App\Process\Service\ProcessHandlerInterface;

class SendMassEmailBulkAction implements ProcessHandlerInterface
{
    protected const MSG_OPTIONS_NOT_FOUND = 'Process options is not defined';
    protected const PROCESS_TYPE = 'bulk-send-mass-email';

    /**
     * @var ModuleNameMapperInterface
     */
    private $moduleNameMapper;

    /**
     * SendMassEmailBulkAction constructor.
     * @param ModuleNameMapperInterface $moduleNameMapper
     */
    public function __construct(ModuleNameMapperInterface $moduleNameMapper)
    {
        $this->moduleNameMapper = $moduleNameMapper;
    }

    /**
     * @inheritDoc
     */
    public function getProcessType(): string
    {
        return self::PROCESS_TYPE;
    }

    /**
     * @inheritDoc
     */
    public function requiredAuthRole(): string
    {
        return 'ROLE_USER';
    }

    /**
     * @inheritDoc
     */
    public function configure(Process $process): void
    {
        //This process is synchronous
        //We aren't going to store a record on db
        //thus we will use process type as the id
        $process->setId(self::PROCESS_TYPE);
        $process->setAsync(false);
    }

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

        $options = $process->getOptions();
        [
            'module' => $baseModule,
            'ids' => $baseIds
        ] = $options;

        ['modalRecord' => $modalRecord] = $options;
        [
            'module' => $modalModule,
            'id' => $modalId
        ] = $modalRecord;

        if (empty($baseModule) || empty($baseIds) || empty($modalModule) || empty($modalId)) {
            throw new InvalidArgumentException(self::MSG_OPTIONS_NOT_FOUND);
        }
    }

    /**
     * @inheritDoc
     */
    public function run(Process $process)
    {
        $options = $process->getOptions();

        $responseData = $this->getDownloadData($options);

        $process->setStatus('success');
        $process->setMessages([]);
        $process->setData($responseData);
    }

    /**
     * @param array|null $options
     * @return array
     */
    protected function getDownloadData(?array $options): array
    {

        ['modalRecord' => $modalRecord] = $options;
        [
            'id' => $modalId
        ] = $modalRecord;

        $responseData = [
            'handler' => 'export',
            'params' => [
                'url' => 'legacy/index.php?templateID='.$modalId.'&entryPoint=formLetter',
                'formData' => []
            ]
        ];

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

            return $responseData;
        }

        return $responseData;
    }

    /**
     * Get request data based on a list of ids
     * @param array|null $options
     * @param array $responseData
     * @return array
     */
    protected function getIdBasedRequestData(?array $options, array $responseData): array
    {

        [
            'module' => $baseModule,
            'ids' => $baseIds
        ] = $options;

        $responseData['params']['formData'] = [
            'uid' => implode(',', $baseIds),
            'module' => $this->moduleNameMapper->toLegacy($baseModule),
            'action' => 'index'
        ];

        return $responseData;
    }

}

Thanks
Asif Khalyani

Hi @offshoreevolution,

Thanks for the additional info!

From my own understanding, the most simple way to implement the Suite7 code directly would be to swap the module into “Compatibility” mode. This tells the module to use the Suite7 frontend by embedding it within the page. Sadly in doing so you do lose some of the functionality added by Suite8 along with losing the new look (It’s pretty close but physically feels different).

To try this out;
Have a look for and open the following file > config/services/module/nano module_routing.yaml

and edit the contacts section to look like this;

contacts:
      index: true
      list: true
      record: false

Which should turn only affect the record view.

Let me know how you get on or if this solution isn’t preferable and I’ll tag in some devs who may be able to help :+1:

Hi @Mac-Rae

Thanks for making the legacy code for contact. But I want similar functionality in Suite8.

  1. Add a new button in the Contact List view → Bulk Action → Send Mass Email (After the Print PDF)
    screenshot-2022.06.13-10_18_11

  2. Click on Send Mass Email and Open popup window → Choose Email Template → Set From Email → Click on Send button → All selected contact record from list view to send the email.

Can you tag in some devs who may help me?

Thanks
Asif

Hi @offshoreevolution,

If you do wish to make changes directly to the Suite8 interface and not a module in backwards compatibility mode you must make those changes within Suite8 and not within public/legacy/. You’d want to achieve this via the Extension Framework.

I’ll tag @clemente.raposo & @Jack_Anderson who are far more clued in on Suite8 development and may be able to assist you at some point over the next few days.

Thanks,
Mac

Hi @clemente.raposo & @Jack_Anderson

Can you guide me? How can I open a modal popup for selecting an email template and sending an email?

Thanks
Asif Khalyani

@offshoreevolution, per our Forums rules, please don’t include company links as “signatures” under posts. You can put that information in your user profile, it will show when people click on your username.

Thanks! :+1:

Apologies, I will take create. It was by mistake. Thanks

1 Like