Hi @rumburak,
Welcome to the community ! and thanks for trying out SuiteCRM 8.
The documentation on how to do this on SuiteCRM 8 has not been added yet.
However, there is already one example of something similar in the core app. Here are some steps to look into.
Note: To do this customization you’ll need to understand how Symfony dependency injection works.
Make the button appear on the front end
Note the following example comes from core but you should add it to the public/legacy/custom/<module>/metadata
To add the button you need to add a new entry to the new recordActions
in detailviewdefs
.
Next you can see an example that already exists on core
From the example there are important things to having in mind:
- the
key
(print-as-pdf
) should be a unique name, as it will also be used to identify the process that is going to handle that action. - Make sure to set
'asyncProcess' => true,
as you want a process that is handled in the backend. By the way by asyncProcess, it means a process that is handled in the backend. - the
modes
defines if the button should be displayed indetail
andedit
or just in one. - You can remove the
params
Example: public/legacy/modules/Accounts/metadata/detailviewdefs.php
'recordActions' => [
'actions' => [
'print-as-pdf' => [
'key' => 'print-as-pdf',
'labelKey' => 'LBL_PRINT_AS_PDF',
'asyncProcess' => true,
'modes' => ['detail'],
'acl' => ['view'],
'aclModule' => 'AOS_PDF_Templates',
'params' => [
'selectModal' => [
'module' => 'AOS_PDF_Templates'
]
]
]
]
],
Add the service to handle the backend
Add your service to something like:
- for services used in multiple modules
-
extensions/<extension-name>/backend/<domain>/Services
- domain is the scope of the change you want to do ex: its languages, statistics,etc
-
- for services that are module specific
extensions/<extension-name>/modules/<Module>/Services
You can find an example of an action in core/backend/Process/Service/RecordActions/PrintAsPdfAction.php
One thing to have in mind is that the namespace must match the path were you added the file, and its case sensitive. If you add a file to extensions/myExt/modules/Accounts/Services/AccountSpecialPdfPrintAction.php
the namespace need to be something like
namespace App\Extension\myext\module\Accounts\Service;
Hope this helps