Create custom button near text field in detail of record

How can I add a custom button in detail view near a field and then, when it pressed, invoke an php script?

I would like to have the same result of “Copy” button in account module for address informations, and upgrade safe.

Can someone help me?
Thank you so much.

Have you looked into creating a new SugarField?

Other solution is to add the button to the view in general. Take a look into this post:



@pgr what do you mean ?

Thank you

SuiteCRM can be extended to have more field types. You can find many things online regarding SugarFields.

A complete example is here

With a new field you can add whatever elements you need to the HTML.

@pgr, oh, ok. You mean to create a new field type.
In my case, I need to add the button near the “name” field in my custom module, and I think I can’t change the fieldtype of the field. or I’m wrong?


I don’t see why you can’t change the field type, or customize the existing field type.

Maybe Name is a special case of a field, because it doesn’t exist in the database (only First name and Last Name are there). I seem to recall that Name is defined in the vardefs as a concatentation of those? Not sure. Maybe there’s even a SugarField for it already…

Sorry, I try to explain better.
name is the required field of my custom module.
And in this my custom module, I would like to add the button near the name field. The result that I’d like to reach is similar than the “copy” button in detailview for account.
So, How can I change the type of this field?

You set the field type normally, in Studio or directly in vardefs.

After you create a new SugarField, a new type exists that you can use for fields, just like you use the built-in types (text, date, etc)

Hello @pgr, I think a custom field type is a solution not necessary (and not to easy to implement) for my goal. Maybe in the future for other needs.
I resolve using “links” element into array defined in detailvardefs, so my button appears in top-right position of record detail (above pagination). The button is not near my field, but for our purposes, that’s okay too.

Thank you very much for your help.

Hmm can you teach me how to do that? And maybe post a screenshot also.


Of course:
this is the result:

Custom button “RESET PASSWORD”.

This is code included into custom/modules/myModule/metadata/detailviewdefs.php

'links' => 
    array (
      0 => '<input type="button" class="button" onclick="setTemporaryPwdForLicense({$});" name="button" id="view_status_button" value="Reset Password" />',


1 Like

If I wanted to use this button to trigger a workflow what would I replace in this?

'links' => 
    array (
      0 => '<input type="button" class="button" onclick="setTemporaryPwdForLicense({$});" name="button" id="view_status_button" value="Reset Password" />',

I would like the button to trigger a send email workflow.

I did that for my PowerWorkflows add-on but I’m afraid it’s a bit too complicated to explain here in detail…

I used Javascript to call the server via Ajax, and on the server had a custom controller action to trigger the Workflow.