Hi @all
I’am playing around with the displayLogic function to show/hide fields on certain conditions. Currently I’d like to show a dropdown field for a lost reason when the sales stage is set to “closed lost”.
So I added the custom field and edited the file custom/Extension/modules/Opportunities/Ext/Vardefs/_override_sugarfield_opty_lost_reason_c.php
as follow:
$dictionary['Opportunity']['fields']['opty_lost_reason_c']['inline_edit']='1';
$dictionary['Opportunity']['fields']['opty_lost_reason_c']['labelValue']='Lost reason';
$dictionary['Opportunity']['fields']['opty_lost_reason_c'] = array(
'displayLogic' => [
'show_on_lost' => [
'key' => 'displayType',
'modes' => ['detail','edit','create'],
'params' => [
'fieldDependencies' => [
'sales_stage',
],
'targetDisplayType' => 'show',
'activeOnFields' => [
'sales_stage' => ['Closed Lost'],
]
]
],
]
);
I set the 'targetDisplayType' => 'show'
according to the docs Adding Field Display Logic" in section “Target Display Type”. After a Quick Repair and clearing the browsers cache, the desired behaviour wasn’t there. Actually nothing happend. I tried it a few weeks ago with the same result. So I had to Invert the logic and HIDE the field on certain conditions - which impo is a complete nonsense - meaning list all the options, where the field is hidden:
$dictionary['Opportunity']['fields']['opty_lost_reason_c']['inline_edit']='1';
$dictionary['Opportunity']['fields']['opty_lost_reason_c']['labelValue']='Lost reason';
$dictionary['Opportunity']['fields']['opty_lost_reason_c'] = array(
'displayLogic' => [
'show_on_lost0' => [
'key' => 'displayType',
'modes' => ['detail','edit','create'],
'params' => [
'fieldDependencies' => [
'sales_stage',
],
'targetDisplayType' => 'none',
'activeOnFields' => [
'sales_stage' => ['Prospecting'],
]
]
],
'show_on_lost1' => [
'key' => 'displayType',
'modes' => ['detail','edit','create'],
'params' => [
'fieldDependencies' => [
'sales_stage',
],
'targetDisplayType' => 'none',
'activeOnFields' => [
'sales_stage' => ['Qualification'],
]
]
],
...and so on with all the rest of the options...
]
);
This is working fine but complicated, since I have to update the code everytime I would add another option to the list. Is there a better way or is this by design? Thank you for your help.
Btw: I am using SuiteCRM 8.7.1 with PHP 8.1
Cheers,
Carsten