AnsweredAssumed Answered

Sugar 7 and backward compatibility modules : overriding view.edit.php

Question asked by Gaelle Fernandez on Jul 21, 2014
Hello everybody,
I'm encountering a big issue on Meetings module, on Sugar 7.2.0 Pro.

I've needed to override the edit view of this module, first to add addToValidate() and removeToValidate() function to several fields, depending on several conditions to have a direct result visible.

I've encountered a js error saying "Uncaught ReferenceError: GLOBAL_REGISTRY is not defined" and all the date fields are not working well.

So, i thought it was my code that did it, so i've totally disabled the view.edit.php by renaming it view.edit.php.old. After QRR, the js error has disappeared.

But now, i need a simple customization : on a contact custom related field, i need to override the button to add a initial_filter to the popup.

here is my new custom/modules/Meetings/views/view.edit.php :

<?php if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
class ContactsViewEdit extends ViewEdit { 
    function display() { 
  echo "
  var sel_account_id = document.getElementsByName(\"parent_id\")[0];
  document.getElementsByName('btn_contacts_c')[0].attributes['onclick'].value = 'javascript:var initial_filter_str = \"&account_id_advanced=\"+sel_account_id.value; open_popup(\"Contacts\", 600, 600, initial_filter_str, true, false, {\"call_back_function\":\"set_return\",\"form_name\":\"EditView\",\"field_to_name_array\":{\"id\":\"contact_id_c\",\"last_name\":\"contacts_c\"}}, \"single\", true);';


This add a filter to the contact popup to call contacts depending on parent_name.
this works, but the js error about global registry came back.

(i found the code on this old thread :

So, after giving you my problems, here is my question :

HOW DO I OVERRIDE A VIEW by adding javascript in a Backward Compatibility Module?

Thanks a lot for giving me clues, or helping me getting on the right tracks!