This is the Opportunity edit view.
I want to show the save button only when there are any changes in the Opportunity record.
If the user presses edit and nothing has been updated, then the save option should not be visible.
How can I achieve this?
is this achievable to implement?
if you reached anything please tell us
No idea about the code for checking if the current opportunity record data is dirty or changed. I am able to hide the ‘SAVE’ button if the status of opportunity is either Won or Lost and show the button if the opportunity is active. I following steps helped for this implementation.
STEPS:
- Create a new file at ‘{ROOT}\extensions\defaultExt\config\modules\Opportunities\recordview\actions\DisableSave.php’
with the following code
<?php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
return static function (ContainerBuilder $container): void {
$actions = $container->getParameter('module.recordview.actions') ?? [];
$modules = $actions['modules'] ?? [];
$opportunities = $modules['opportunities'] ?? [];
$recordActions = $opportunities['actions'] ?? [];
$save_action=$actions['default']['actions']['save'];
$save_action['display']='hide';
$save_action['displayLogic'] = [
'save-visible'=>[
'key' => 'displayType',
'modes' => ['edit'],
'params' => [
'fieldDependencies' => ['sales_stage'],
'targetDisplayType' => 'default',
'activeOnFields' => [
'sales_stage' => [['operator'=>'not-equal','values'=>['Closed Won','Closed Lost']]],
],
],
],
];
$recordActions['save']=$save_action;
$opportunities['actions'] = $recordActions;
$modules['opportunities'] = $opportunities;
$actions['modules'] = $modules;
$container->setParameter('module.recordview.actions', $actions);
};
- Run the command from the root folder of suite8 instance
php bin/console cache:clear
- Clear browser cache to test the above code