How to dynamically pull choices to be filled in

We have a Account type field that has values of “Partner” or “Customer”
Our Partners give us opportunities.
We would like to keep track of the tie between an Opportunity and which Partner, and which contact at the Partner gave us that Opportunity.
So when we added Partner into the Opportunity module and tied it to accounts, that works great, but we would like to allow the drop-down in the Opportunity (Where you choose the “Partner”) to only list accounts that are labeled as “Partner”.
Similarly when you select the Partner Contact in Opportunity, we only want you to be able to choose contacts that are at the Partner.
I have spent hours on google and reading the documentation around Metadata and Vardefs, and don’t see anything like that.

Hi @Mark.Hortman,

Welcome to the community :tada:

Thanks for doing your research before reaching out. I’ll ask about and see if I can find and example of this being done however in the meantime maybe have a look into using and process_record logic hook to update the value on the page with the related data you need.

If you have any luck, let me know!

You should check out Function dropdown fields. Here is a sample of how to define that field.

$dictionary[‘Opportunity’][‘fields’][‘partner’] = array (
‘name’ => ‘partner’,
‘vname’ => 'LBL_PARTNER,
‘type’ => ‘enum’,
‘function’ =>
array (
‘name’ => ‘getPartnerAccounts’,
‘returns’ => ‘html’,
‘onListView’ => true,
),
‘function_params’ =>
array (
0 => ‘id’,
),
‘sortable’ => false,
‘reportable’ => false,
);

You can define the getPartnerAccounts function in custom utils, by creating a file at /custom/Extension/application/Ext/Utils/customUtils.php

The function should return html OPTIONS only for the Select to populate the dropdown.

Interesting post.

There is a variation on this technique (without returning HTML) and a different solution here:

1 Like