Add a Button to Cases Programatically?

I would like to add a custom button (without removing exisiting buttons) to the Cases Edit View. I only want the button to show when the Case Type is of a specific value and only if the User is in a particular Security Group.

I have not been able to achieve this by modifying the editviewdefs.php. Is there is a way to do this in the editviewdefs.php?

Is there another way to do this?

I found this in the developers guide but have not figured out how to use it.

The ParserFactory
The ParserFactory can be used to manipulate layouts such as editviewdefs or
detailviewdefs. This is a handy when creating custom plugins and needing to
merge changes into an existing layout.

The following example will demonstrate
how to add a button to the detail view:

> //Instantiate the parser factory for the Accounts DetailView.
> require_once('modules/ModuleBuilder/parsers/ParserFactory.php');
> $parser = ParserFactory::getParser('detailview', 'Accounts');
> //Button to add
> $button = array(
> 'customCode'=>'<input type="button" name="customButton"
> value="Custom Button">'
> );
> //Add button into the parsed layout
> array_push($parser->_viewdefs['templateMeta']['form']['buttons'],$button);
> //Save the layout
> $parser->handleSave(false);



Where do you want to display the button? What view?

I want to put the Button in the Cases Edit View

Not sure if it works but try to create file: custom/Extension/modules/Cases/Ext/Vardefs/my_custom_button.php

    $dictionary['Case']['fields']['custom_button_field'] = array(
        'name' => 'custom_button_field',
        'vname' => 'LBL_MY_CUSTOM_BUTTON_LABEL',
        'type' => 'button',
        'readonly' => true,
        'onClick' => 'javascript:my_CustomButtonFunction();',

Then create file custom/modules/Cases/custom.js to create your JavaScript functions. In this case function my_CustomButtonFunction() to add your logic for that button.

After that go to Quick Repair. Also Run the Run Relationships in case is needed.