Run a php script on a field in each record

Hey all, I need to hash a field in my custome module but need sugar to hash the field in every record and save the hash over the original value

My php script to hash 

    public function obfuscate($action, $string) 
    {
        $output               = false;
        $encrypt_method     = "AES-256-CBC";
        $key           = hash('sha256', self::$salts[0]);
        $iv                     = substr(hash('sha256', self::$secret_iv), 0, 16);

        if ($action == 'encrypt') {
            $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
            $output = base64_encode($output);
        } else if ($action == 'decrypt') {
            $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
        }
        return $output;
    }

 I just wandered how id call a php function, would  need to create a custom button on the records view 

  • What is the version of your SugarCRM instance?

    Perhaps you can create an endpoint which invokes such method. This endpoint can be reached by a js event behind the button.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • André Lopes, thanks for the reply,We are running v10 enterprise, is there a tutorial on doing what you suggest as Ive not looked at custom buttons yet?