Menu
SuiteCRM Pull Request Party hosted by SalesAgility
Welcome, Guest
Username: Password: Remember me

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

Auto Populate Custom Field in Quotes Module with Information From Accounts Module 6 months 1 week ago #75409

  • henryn
  • henryn's Avatar
  • Offline
  • New Member
  • Posts: 1
  • Karma: 0
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. :)
Last Edit: 6 months 1 week ago by pgr. Reason: add code tags
The administrator has disabled public write access.

Auto Populate Custom Field in Quotes Module with Information From Accounts Module 6 months 1 week ago #75431

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10197
  • Thank you received: 1531
  • Karma: 352
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.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Auto Populate Custom Field in Quotes Module with Information From Accounts Module 5 months 18 hours ago #76672

  • snice
  • snice's Avatar
  • Offline
  • New Member
  • Posts: 1
  • Karma: 0
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
The administrator has disabled public write access.
Time to create page: 0.050 seconds
Powered by Kunena Forum