Fields as a choice in another field

Hi

I have two fields in a company module:
Site ID = the ID number we use internally for a company
Outlet code = the ID number our customer uses for a company

I now want to include these fields on the “Create Case” form so that

  1. The Site IDs and Outlet Codes already existing in the company module are options in these fields when I create the case.
  2. When either the Site ID is entered on the “Create Case” form, the corresponding Outlet code auto-populates and vice versa.

I hope this can be done.

Thanks,

You just need to create extended vardefs for Accounts and Cases.

On Accounts extended vardefs you have to add the attribute “populate_list” on field “cases”:

$dictionary[‘Account’][‘fields’][‘cases’][‘populate_list’] = array(
‘account_field_1’ => ‘case_field_1’,
‘account_field_2’ => ‘case_field_2’,
);

On Cases extended vardefs you have to add the attribute “populate_list” on field “account_name”:

$dictionary[‘Case’][‘fields’][‘account_name’][‘populate_list’] = array(
‘account_field_1’ => ‘case_field_1’,
‘account_field_2’ => ‘case_field_2’,
);

Remember to run Quick Repair and Rebuild from Admin -> Repair

Regards

1 Like

Thanks for that.

I’m not a developer though. Is this something I can do?

I take it there’s no way to do this in Studio.

Definitely there is no way to accomplish that through inside Studio.

I’ve done this with a developers help.
I.e. I edited vardefs.ext.php for the relevant modules to include the code you sent.

The changes to vardefs saved, but when I run Quick Repair and Rebuild, the vardefs.ext.php files revert to the earlier versions without the new code.

Probably you edited the file custom/modules/Accounts/Ext/Vardefs/vardefs.ext.php. This file is rebuilt on running Quick Repair and Rebuild.
You have to create a php file inside custom/Extension/Accounts/Ext/Vardefs/ and save into that the codes I previously provided. After than run Quick Repair and Rebuild.

Regards

Thanks again.
I’ve done this. How does this translate to what I see in Suite CRM?

You need to know the fields name on Accounts and respective fields name on Cases and then update such attribute as well.

Thanks again.

So if I have created a package called Gsites.
Within it is a module called Sites (based on accounts).
In my file structure, the module shows as custom/Extension/modules/sit01_SitesModule/

The fields I want to relate between modules are:
SiteID - In the fields list of the module builder, the field name shows as siteid_c and the system label shows LBL_SITEID
Outlet Code - In the fields list of the module builder, the field name shows as outletcode_c and the system label shows LBL_OUTLETCODE

Are the system labels important?

Going from your earlier post, should I then go to Cases extended vardefs and add:
$dictionary[‘Case’][‘fields’][‘sit01_SitesModule’][‘populate_list’] = array(
‘sit01_SitesModule_siteid_c’ => ‘case_siteid_c’,
‘sit01_SitesModule_outletcode_c’ => ‘case_outletcode_c’,
);

Or have I misunderstood?

The fact is that you don’t need to worry about the name of field including its module, you just need to place the field’s name itself, for example:
Lets say you want to copy from Accounts to Cases the built in fields industry and account_type.
In Cases you created the fields industry_c and account_type_c, so the populate_list should be:

$dictionary[‘Account’][‘fields’][‘cases’][‘populate_list’] = array(
‘industry’ => ‘industry_c’,
‘account_type’ => ‘account_type_c’,
);

Eventually the universe is simpler than we initially figured out.

:grin:

Using your example above:
Let’s say I have 20 accounts records. Each record has a text value in the industry field.
I add the industry_c field to the ‘Edit’ layout of cases using Studio.
If I then go to edit a case and go to the industry_c field and start to type, will I see a dropdown showing the fields from the accounts record?

According to this

https://community.sugarcrm.com/thread/34370-looking-for-documentation-on-populatelist

this populate_list property is exclusive to Relate fields (which makes sense). Check if that is the case in your database.