Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6128291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:36:37+00:00 2026-05-23T16:36:37+00:00

I made module addition and in this made three fields amount1_c , amount2_c and

  • 0

I made module addition and in this made three fields amount1_c, amount2_c and total_amount_c to add the two numbers and display the result in the third field. I done coding in the logic looks here is my code

<?
$hook_version = 1;     
$hook_array = Array();      
$hook_array['before_save'] = Array();     
$hook_array['before_save'][] = Array(1,'calculate_field', 'custom/modules/cases/LogicHookMath.php','LogicHookMath', 'calculate_field');    
?> 

and made one more file logic hook math. here is my code for

<?php
class LogicHookMath {
    function calculate_field(&$bean, $event, $arguments) {
        $field1 = $bean->amount1_c;
        $field2 = $bean->amount2_c;
        $field3 = $field1 + $field2;
        $bean->amount_total_c = $field3;
    }
}
?>

but still i did not get any result. Please help me out for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:36:38+00:00Added an answer on May 23, 2026 at 4:36 pm

    The code looks correct.

    Some common “mistakes” when custom logic hooks are not working:

    • Make sure, the custom logic hook has the correct name (LogicHookMath.php)
    • Make sure, that the $bean variable is prefixed with &, so the variable is passed as a reference
    • Make sure the logic_hooks.php and the LogicHookMath.php files are readable by the web server user
    • The entire custom directory should also be writeable for the web server user

    If the above does not help, try logging the progress to the sugarcrm.log using $GLOBALS['log']->info( "Value 3: ". $field3); in the custom logic hook.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to add a method to two models, so I made a module
This module is part of a simple todo app I made with Python... def
I have a multi-module maven project made up of three sub-modules: web , service
I am using a Joomla module (ArogaRousel) that was made to display images of
I have made up the custom module as : YUI.add('util', function(Y) { Y.namespace('com.myCompany'); var
I have a custom module I made for Magento. From the admin, there is
I have a custom module I made to show featured products on the homepage.
Made solution change: I am trying to display a html table of data.. In
Made this nice little loop for hiding and showing div's, works as a charm
Hi we have made a module for a controller and that module uses the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.