Auto Populate Custom Field in Quotes Module with Information From Accounts Module

Hello Everyone. I am new to SuiteCRM and currently stuck trying to figure out a particular customization. I have searched the forum and the web but still couldn’t figure it out as programming is not my forte. Hence, I have opened a new post seeking for help.

In the quotes module, if I click on the Account field, the billing & shipping addresses will auto populate from the Accounts Module.
I have created a custom field PHONE_OFFICE_C and would like to auto populate from the Accounts Module as well (PHONE_OFFICE).

a) I have tried to modify the controller.php (AOS_Quotes) using $bean but it does not work (perhaps my understanding is incorrect).

if (isset($_REQUEST['account_id'])) {
            $query = "SELECT * FROM accounts WHERE id = '{$_REQUEST['account_id']}'";
            $result = $this->bean->db->query($query, true);
            $row = $this->bean->db->fetchByAssoc($result);
            $this->bean->billing_account_id = $row['id'];
	    $this->bean->phone_office_c = $row['phone_office'];    // <-----------------
	    $this->bean->billing_account = $row['name'];
	    $this->bean->billing_address_street = $row['billing_address_street'];
            $this->bean->billing_address_city = $row['billing_address_city'];
            $this->bean->billing_address_state = $row['billing_address_state'];
            $this->bean->billing_address_postalcode = $row['billing_address_postalcode'];
            $this->bean->billing_address_country = $row['billing_address_country'];
            $this->bean->shipping_address_street = $row['shipping_address_street'];
            $this->bean->shipping_address_city = $row['shipping_address_city'];
            $this->bean->shipping_address_state = $row['shipping_address_state'];
            $this->bean->shipping_address_postalcode = $row['shipping_address_postalcode'];
            $this->bean->shipping_address_country = $row['shipping_address_country'];

b) I have also tried to use ‘displayParams’ but no avail (editviewdefs.php under customs AOS_Quotes). I have used ‘key’ => ‘billing’, and have tried to use “field_to_name_array” but neither works. Most likely my coding is incorrect as well.

1 => 
          array (
            'name' => 'phone_office_c',
			'label' => 'LBL_PHONE_OFFICE',
			'displayParams' =>
            array(
              'key' => 'billing',
            ),
			
			//'studio' => 'visible',
			//'displayParams' =>
			//array(
			//	'field_to_name_array' => array(
			//	'id' => 'account_id',
			//	'name' => 'account_contact',
			//	'phone_office' => 'phone_office_c',
			//),
			//'additionalFields' => array(
			//	'phone_office' => 'phone_office_c',
			//),
			//),
          ),

Any guidance and correct coding help is greatly appreciated. :slight_smile:

Hi.

I added code tags to your post - otherwise some parts of your code don’t show correctly.

I suggest you read about logic hooks in the Developer Guide, and about Beans.

Then search for an example doing this from an after_save logic hook, it’s the correct approach, I believe.

Hi henryn,

I’m exactly in the same situation! I tried many things without any success.

Did you manage to get it working? If yes, could you please tell me what you did exactly?

Thank you