I have been trying to add a custom button in the DetailView of the Contacts module. The purpose of this button is to trigger a specific action when clicked.
I’ve added the custom button to the detailviewdefs.php
file for the Contacts module. The custom button is defined in recordActions
and is supposed to invoke a custom service for further processing.
'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'
]
]
] ,
'custom-button-action' => [
'key' => 'custom-button-action',
'labelKey' => 'LBL_CUSTOM_BUTTON',
'asyncProcess' => true,
'modes' => ['detail'],
'acl' => ['view'],
'aclModule' => 'Contacts',
'service' => 'CustomButtonHandler',
] ,
]
],
I’ve also created the corresponding service class in the location core/backend/Process/Service/RecordActions/CustomButtonHandler.php
[ have also tried the location extensions/defaultExt/backend/modules/Contacts/Services/CustomButtonHandler.php
]
When I click the custom button in the Contacts DetailView, I receive an “Unexpected error when calling action” message.
I would greatly appreciate any assistance, suggestions, or insights from the community to help me resolve this issue and get the custom button functioning correctly.
Thank you in advance for your support!