How to pass field parameter to customCode button calling javascript

i am trying to create a button in DetailView that calls a javascript.
This javascript, then calls(ajax) a custom Controller action to retrieve some data.
To do this the javascript function needs to have as input the id of record.

I’ve tried this without luck:

function display()
        $this->dv->defs['templateMeta']['form']['buttons'][101] = array (
            'customCode' => '<input title="Activate" accesskey="{$APP.LBL_PRINT_PDF_BUTTON_KEY}" class="button" onClick="javascript:activate({$});" name="activate" value="Activate" type="button">');

The returned error putting {$} as input is:
Uncaught SyntaxError: identifier starts immediately after numeric literal

How can i pass id of field into javascript funcion?

Many thanks

You need to surround {$} with quotes:

1 Like

It works like a charm!

i want to pass module name and user id , My work is that i created a button on detailview and on click i want to pass module name and current_user_id ,while id is passing ,module name is not pasiing
detailviewdefs code is : array(
‘name’=> ‘my_custom_field’,
‘customCode’ => ‘’,
‘label’ => ‘LBL_MY_CUSTOM_FIELD’,