Note that there are some explanatory texts on larger screens.

plurals
  1. POSugarCRM- How to get POPUP when click on Save button?
    primarykey
    data
    text
    <p>I want when click Save in Edit View of some module (example Contact) to get pop up with some message (later I will get options OK and Cancel on that pop up.).</p> <p>My function </p> <pre><code>YAHOO.SUGAR.MessageBox.show({msg: 'Foo'} ); </code></pre> <p>is working when I put it at top of editviewdefs.php (I also must include <code>cache/include/javascript/sugar_grp_yui_widgets.js</code>) ) file and when opening that view I am getting that pop up. But I want it to popup on Save,not when opening EditView (this was just testing that showed me that <code>YAHOO</code> function is working). So I try to create seperate <code>customJavascript.js</code> file in <code>custom/modules/Contacts</code>:</p> <pre><code> //&lt;script type="text/javascript" src="cache/include/javascript/sugar_grp_yui_widgets.js"&gt;&lt;/script&gt; function check_custom_data() { YAHOO.SUGAR.MessageBox.show({msg: 'Foo'} ); } </code></pre> <p>I modified <code>custom/modules/Contacts/metadata/editviewdefs.php</code></p> <pre><code>&lt;?php $module_name = 'Contacts'; $viewdefs ['Contacts'] = array ( 'EditView' =&gt; array ( 'templateMeta' =&gt; array ( 'form' =&gt; array ( 'hidden' =&gt; array ( 0 =&gt; '&lt;input type="hidden" name="opportunity_id" value="{$smarty.request.opportunity_id}"&gt;', 1 =&gt; '&lt;input type="hidden" name="case_id" value="{$smarty.request.case_id}"&gt;', 2 =&gt; '&lt;input type="hidden" name="bug_id" value="{$smarty.request.bug_id}"&gt;', 3 =&gt; '&lt;input type="hidden" name="email_id" value="{$smarty.request.email_id}"&gt;', 4 =&gt; '&lt;input type="hidden" name="inbound_email_id" value="{$smarty.request.inbound_email_id}"&gt;', ), ), array( 'buttons' =&gt; array ( 0 =&gt; array( 'customCode' =&gt; '&lt;input title="Save [Alt+S]" accessKey="S" onclick="this.form.action.value=\'Save\'; return check_custom_data();" type="submit" name="button" value="'.$GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'].'"&gt;', ), 1 =&gt;'Cancel' ) ), 'includes'=&gt; array( array('file'=&gt;'custom/modules/Contacts/customJavascript.js'), ), .......... ....... </code></pre> <p>but when I click Save in EditView nothing happens but I want in that moment to get pop up with message (later I will add OK and Cancel options).</p> <p>What am I doing wrong? thank you</p> <p>Updated with code for pop up only with some condition:</p> <pre><code>.... window.formToCheck = formname; var contactTypeField = document.getElementById('first_name'); if (contactTypeField.value == 'Tori') { if (confirm("This dialog will pop-up whenever the user click on the Save button. " + "If you click OK, then you can execute some custom code, and then " + "execute the old form check function, which will process and submit " + "the form, using SugarCRM's standard behavior.")) { var customCodeVariable = 5; customCodeVariable = 55 + (customCodeVariable * 5); return window.old_check_form(formname); } return false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload