Set condition before clicking "Save" button in a module.

How do i set a condition on a button.
Lets say i have a field call "Numbers".
If the number exceeds 50, the user will not be allowed to save the record.
If the user clicks the "Save" an error message will appear on the screen saying" Exceed 50".

I am using sugar ce ver 6.5
Parents
  • Hi Yuenchee Chan,


    First you need create logic_hooks.php in custom/modules/

    In logic_hooks.php file:
    <?php
        $hook_version = 1;
        $hook_array = Array();

        $hook_array['before_save'] = Array();
        $hook_array['before_save'][] = Array(
            //Processing index. For sorting the array.
            1, 
            
            //Label. A string value to identify the hook.
            'before_entry_point example', 
            
            //The PHP file where your class is located.
            'custom/modules/logic_hooks_class.php',
            
            //The class the method is in. 
            'logic_hooks_class',
            
            //The method to call. 
            'before_entry_point_method' 
        );

    ?>


    Then you need to create logic_hooks_class.php in custom/modules/

    In logic_hooks_class.php File:

    <?php
        if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
       
        class logic_hooks_class
        {
            function before_entry_point_method($bean,$event, $arguments)
            {
                // here you need to code your requirement
            }
        }

    ?>
  • Hi thanks a lot for the help! May i know what are the codes required for me to display the error message?
Reply Children
No Data