Delete entry in a sub pannel, not available since suiteCRM 8

Hello there,

Finally migrating to SuiteCRM8.
PHP 8.2
Suite CRM 8.7.0

Im trying to know if there is any way to re implement the delete button on a subpannel entry?
Now the button only unlink the entry, but I want to delete completely a Note attached to an Account.

Tried to force the /custom/modules/Notes/metadata/subpanels/Account_subpanel_accounts_notes_1.php
And add the delete_button like in suiteCRM 7, but it do nothing.
Now it’s remove_button, that is used to unlink.

Will I need to re code this myself or there is a tip to have it back ?

Have a wonderfull day!

I believe that even in v7, the buttons in subpanels usually unlink records instead of deleting them. In other words: they delete the relationship, but not the target record itself.

In order to create a real “delete” button i na subpanel, you would need to do it the v8 way, changing metadata by injecting the differences into the configuration.

See SuiteCRM Developer Insights - Adding Bulk Actions for an example with List views actions. If you examine the metadata getting sent when doing a full screen refresh on a Record view, you can see the similar things done for subpanel actions.

Hopefully the back-end action already exists (if you can figure out what it’s called) and so you would be able to have the button just call existing code.

2 Likes

No there was a real delete button in sub pannel in V7.
Calling on click javascript:sub_p_del(‘leads_notes_1’, ‘Notes’, ‘27f73b37-34f1-3ef7-a194-673dc7c87c45’, 0);

For a note linked to a lead. And it actually delete the note, not the relationship.

If you go in the studio in V7, to a sub pannel you have two delete/remove buttons.

  • [delete_button]
  • [remove_button]

One delete the entry, the other remove the relationship.

Tried to force in studio or via code to have both, sadly now only remove_button actually display something.

For everyone having the same need :

This could work, just need to customize aswell the icon to like a trash bin or something than make more sense that this unlink icon

When I found the time to do it I’ll paste my code here :slight_smile:

After a while I fixed this.
Sadly its not upgrade safe and didnt found a way to add it in an upgrade safe way.

create /extensions/defaultExt/config/services.yaml (the only upgrade safe file in this method)

parameters:
  module.subpanel.line_actions:
    default:
      actions:
        edit:
          key: edit
          labelKey: LBL_EDIT_RECORD
          action: edit
          icon: edit
          asyncProcess: true
          routing: true
          params:
          modes:
            - list
          acl:
            - edit
        unlink:
          key: unlink
          labelKey: LBL_UNLINK_RECORD
          action: unlink
          icon: unlink
          asyncProcess: true
          routing: false
          params:
            displayConfirmation: true
            confirmationLabel: LBL_UNLINK_RELATIONSHIP_CONFIRM
          modes:
            - list
          acl:
            - edit
        #add delete btn
        delete:
          key: delete
          labelKey: LBL_DELETE
          action: delete
          icon: cross #trash
          asyncProcess: true
          routing: false
          params:
            displayConfirmation: true
            confirmationLabel: NTC_DELETE_CONFIRMATION
          modes:
            - list
          acl:
            - edit

Modify /core/backend/ViewDefinitions/LegacyHandler/SubPanelDefinitionHandler.php
in function getSubpanelLineActions()

//Original
        // $subpanelLineActions = ['edit_button' => 'edit', 'close_button' => 'close', 'remove_button' => 'unlink'];
        //Custom added btn
        $subpanelLineActions = ['edit_button' => 'edit', 'close_button' => 'close', 'remove_button' => 'unlink', 'delete_button' => 'delete'];

I also modified /core/backend/Process/Service/RecordActions/DeleteRecordAction.php to not redirect to the module after delete an entry.

Then I just edited subpanel metadata like in v7 to change the remove_button to delete_button
/public/legacy/custom/modules/Notes/metadata/subpanels/Lead_subpanel_leads_notes_1.php

If someone have an upgrade safe methode please share here :pray:

I am running a 7.x, and never saw a delete button, only the remove button.
Even now there is no [delete_button] in Studio for me.

Its cause they are a bit hidden.

U have delete_button that delete the entry and remove_button that only deletethe relationship.

Search those in core file and you will see that both exist :slight_smile: