AnsweredAssumed Answered

How can I add javascript to a relate field?

Question asked by Asaf Army on Jun 16, 2014
Latest reply on Jun 25, 2014 by Sagar Salunkhe
using sugarcrm community 6.5.13.
tried for 6 hours to add a javascript event when i choose a contact in a related contact field.
i have a contact related field in AOS_Quotes module.

i added an "include" tothe editviewdefs.php:

'includes' =>       array (
        0 => 
        array (
          'file' => 'custom/modules/AOS_Quotes/AOS_Quotes.js',
        ),
      ),

and adeed a function "hello()" in the javasscript file:

function hello(){
alert("asaf");

}

i tried everything:

 0 =>           array (
            'name' => 'billing_contact',
            'label' => 'LBL_BILLING_CONTACT',
            'displayParams' => 
            array (
            
            // Doesn't work!
            //'javascript' => 'onchange="hello();"',
            
            // Doesn't work!            
            // 'field' => 'onblur="hello();"',
            
            // Doesn't work!
//   'field' =>  
//               array ( 
//                 //'onFocus' => 'hello();',
//                 //'onchange' => 'hello();',
//                 'onblur' => 'hello();',
//                  
//               ),            
            
              //'initial_filter' => '&account_name="+this.form.{$fields.billing_account.name}.value+"',
              
              ),


i already did that before for text field by using customCode:

array       (

          'name' => 'first_name',

        'customCode' => '<input
name="first_name" 
id="first_name" size="30" maxlength="25"
type="text" value="{$fields.first_name.value}"
onblur="checkvalid(first_name.value,ATLEAST_ONE_CHARACTER);">',

        'tabindex' => '1',

                  ),

but i don't know how to write an html for a relate field too.



can anyone hep me please?



Outcomes