Action dropdown custom button works but not in extension framework

Hi,

I was trying to add a button to the “Actions” dropdown on the Contacts Detail View.

  1. The following code works fine when added in ./custom/modules/Contacts/metadata/detailviewdefs.php

  2. From the documentation on the Extension Framework, I thought it would be better practice to put this code in its own file under ./custom/Extension/modules/Contacts/Ext/Vardefs/my_button.php

It works fine in the first case, but it does nothing in Extension. All permissions are verified and correct. Of course, I do a Quick Repair & Rebuild in both cases.

Does anyone have an idea about what I could do to make this work within the Extension framework? It seems better practice, and it would be easier to replicate some customization across clients.

<?php

// define button
$mybutton = array(
  'customCode' => '<input type="button" class="button" onclick="
      message  = \'{$bean->first_name} {$bean->last_name}\\n\';
      message += \'{$bean->phone_mobile}\\n\';
      message += \'{$bean->email1}\\n\';
      navigator.clipboard.writeText(message);
      alert(\'Copied contact details!\');"
    value="Copy details">',
);

// add button
$viewdefs['Contacts']['DetailView']['templateMeta']['form']['buttons'][4]=$mybutton;

?>

Thanks in advance if you have any thoughts !

Viewdefs and vardefs are different things. The first described views, it’s a UI thing; the second describes data.

You can just stay with the version that works. Use the option explained here as “extending” an existing view.

1 Like

@pgr , thanks a lot for your clarification and your suggestion. I suspected it was the case after re-reading the Extension framework. I’ll look into Views.