AnsweredAssumed Answered

How to make a pop-up appear if an account is inactive?

Question asked by Abhay Hans on Aug 7, 2015
Latest reply on Aug 9, 2015 by Abhay Hans

I am new to SugarCRM, so please bear with me. I am trying to add a
pop-up window in SugarCRM. I need this pop-up window to show up whenever   a user clicks on an Account whose status is set to 'Inactive'.

   

Now, I am trying to follow the instructions mentioned in this link   except I am using a little more fancy? pop-up window which are based off   of the YUI 2 SimpleDialog component.

   

SugarCRM- How to get POPUP when click on Save button?

   

Currently, A pop-window appears when I click on the edit button to   edit the accounts. But, I want it to appear in the DetailView, when an   account is inactive a pop up should appear.

   

So far my code looks like this:

sugar version (6.2.20) edition Professional

php 5.3.29


manifest.php:

 <?php          $manifest = array(                  array(                          'acceptable_sugar_versions' => array()                  ),                  array(                          'acceptable_sugar_flavors' => array()                  ),                  'readme' => 'Please consult the operating manual for detailed installation instructions.',                  'key' => 'customSugarMod1',                  'author' => 'Abhay Hans',                  'description' => 'Adds pop-up Message when an account is inactive.',                  'icon' => '',                  'is_uninstallable' => true,                  'name' => 'Pop-Up Dialog if inactive account',                  'published_date' => '2015-07-08 12:00:00',                  'type' => 'module',                  'version' => 'v1.7',                  'remove_tables' => 'prompt'          );            $installdefs = array(                  'id' => 'customSugarMod1',                  'copy' => array(                          array(                                  'from' => '<basepath>/custom/',                                  'to' => 'custom/'                          )                  ),                  'logic_hooks' => array(                          array(                                  'module' => 'Accounts',                                  'hook' => 'after_ui_frame',                                  'order' => 1,                                  'description' => 'Creates pop-up message on load if user inactive',                                  'file' => 'custom/include/customPopUps/custom_popup_js_include.php',                                  'class' => 'CustomPopJs',                                  'function' => 'getAccountJs'                          )                  )          );



Custom_popup_js_include.php:


<?php      // prevent people from accessing this file directly      /*if (! defined('sugarEntry') || ! sugarEntry) {          die('Not a valid entry point.');      }*/      class CustomPopJs {          function getAccountJs($event, $arguments) {              // Prevent this script from being injected anywhere but the EditView.              /*if ($_REQUEST['action'] != 'DetailView' ) {                  // we are not in the EditView, so simply return without injecting                  // the Javascript                  return;              }*/              echo '<script type="text/javascript" src="custom/include/customPopUps/customPopUpAccounts.js"></script>';              echo '<script type="text/javascript" src="custom/include/javascript/sugarwidgets/SugarYUIWidgets.js"></script>';          }      }


customPopUpAccounts.js

document.addEventListener('DOMContentLoaded', function() {      checkUserStatus();  }, false);      function checkUserStatus()  {      if($("#aq_account_status_c").val() != "Active" )      {             YAHOO.SUGAR.MessageBox.show({msg: 'This account is inactive ', title: 'Inactive Account'} );      }    }

Outcomes