Problem adding a simple button to SuiteCRM 8 Account's detailview

Hello guys,
i’ve installed the new version of suitecrm 8 and i’m trying to add a new button in the account detailview page. In custom/modules/Accounts/metadata/detailviewdefs.php i added this code:

but after a quick repair nothing is changed. i tryied to logout, but nothing compare.
what do i missed? Can someone help me? i realy don’t understand

Regards,
Patryk

Hi @pat,

Welcome to the community! :wave: and thanks for trying out SuiteCRM 8.

The metadata configuration for adding buttons changed. The documentation for how to add a button hasn’t been released yet.

What do you want the the button to do?

This thread may help:

Hope this helps.

PS: We’re in the holiday season, so I may take a while to reply back.

Thank you for the answer! i will read everything and i will try again.
I will back here tomorrow :slight_smile:

Yes, no problem, thank you again!

Hi @clemente.raposo i follow the other topic and i managed to create a new action.
image

But i have some question:

  • Is that possibile to open a new page instead of “executing” some code in the run method of my extension?
  • Can i build my personal modal? like in this screenshot?
    image

I found something wierd. Is that a known problem that i can’t see fields of a module in studio?

thank you

Hi @pat ,

Glad to hear you were able make some progress

However I got a bit confused sorry.

What would be the modal for?

Would you like to redirect after opening the modal?

The modal is an idea that i have to implements some nice button.
For example the action is report that open a modal with inside 4 buttons, each open different page with a report.

The redirect i would like to use to open some report from accounts directly.

The modal and the redirect are two different things, sorry if I didnt’ explain well my problem
is it clearer now?

Hi @pat,

Thank you. Yes I think I understand what the goal is.

Creating a custom modal is hard, takes a good amount of time and requires a good knowledge of angular and of the frontend extension framework.

There are 2 alternatives that you could try before going down the custom modal path.

Option 1. Add 4 buttons to re-direct to reports, each for a single report.

There is an easy way to redirect to other pages when a button is pressed. You need to return a redirect handler in the response of your backend async action, something like

    public function run(Process $process)
    {
        $options = $process->getOptions();

        $responseData = [
            'handler' => 'redirect',
            'params' => [
                'route' => $options['module'] . '/convert-lead/' . $options['id'],
                'queryParams' => [
                ]
            ]
        ];

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

There are some examples of it like:

  • core/backend/Process/Service/RecordActions/ConvertLeadAction.php
  • core/backend/Process/Service/RecordActions/DuplicateRecordAction.php
  • and others

Option 2. Add button with a modal that list all reports and redirect to the selected one

This is a modal similar to the one that shows on the Print PDF action, but instead of showing a list of templates, it would show a list of reports.

On your button definition in detailviewdefs you can add the param that you mentioned before, to open a list of all the existing reports (Acls should apply). You can do this like so:

              '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'
                      ]
                  ]
              ]
          ]

Then when a user selects a record, that information will be sent to your backend handler, were you can then build a redirect url like explained on option 1.

The following is an example of to retrieve the selected record information taken from

  • core/backend/Process/LegacyHandler/AddRecordsToTargetListBulkActionHandler.php
   /**
     * @inheritDoc
     */
    public function run(Process $process)
    {
        ....

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

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

        ....
    }

Hope this helps. Please let me know if you have more doubts

can you please share the steps that how you have added a button

Hey @jyotijsr,

I’d suggest opening a fresh topic to allow for people to contribute in a cleaner environment. I’d make sure to link back to this thread using;

https://community.suitecrm.com/t/problem-adding-a-simple-button-to-suitecrm-8-accounts-detailview/83430/

Thanks!

Hi @jyotijsr,

Thanks for trying out SuiteCRM 8.

Most of the steps should be in this thread here:

Hope this helps

@pat @clemente.raposo can you guide me how did you add button in detail view action menu in suitecrm 8

@schalhasnain
You can follow the step

Hello there,

I am getting this error “Unexpected error when calling the action”

So how can I solve it? Can you help me with this?

Thanks.