Menu

Welcome, Guest
Username: Password: Remember me

TOPIC: required fields

required fields 6 days 14 hours ago #69188

  • JorgeT
  • JorgeT's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
sugar 6.5
Hello there, I'm currently working on cases module, on this module I have a field status with the value (Open, Closed) and on the second subpanel called resolution I have a resolution field, what I try to do is when I get status = Closed make the resolution required, I try logic hook but I can set the field to require, It's any way to set the $dictionary on the logic hook? or is there any better way?
The administrator has disabled public write access.

required fields 6 days 14 hours ago #69190

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 6868
  • Thank you received: 1048
  • Karma: 244
Hi! These Forums are for SuiteCRM, not SugarCRM...
The administrator has disabled public write access.

required fields 6 days 14 hours ago #69192

  • JorgeT
  • JorgeT's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
Thanks for your replay, any advice for suiteCRM 7.8?
The administrator has disabled public write access.

required fields 6 days 13 hours ago #69194

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 6868
  • Thank you received: 1048
  • Karma: 244
It's hard to help with code issues unless you post the full code (inside the Forum's "code" tags, please).

Is your Hook running, can you confirm this?
The administrator has disabled public write access.

required fields 6 days 13 hours ago #69197

  • JorgeT
  • JorgeT's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
absolutely, the logic hook is running I also get the value of the field and do a modification to the resolution field but I do not stop me to put some data in the field here is the code:

logic hook:
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(15, 'resolution required', 'custom/modules/Cases/resolution.php', 'resolution','resolution_required');   

resolution.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class resolution{
     
    function resolution_required ($bean, $event, $arguments){
       
        
        $GLOBALS['log']->debug('bean-> '. $bean->state);
        //$GLOBALS['log']->debug('bean1-> '. print_r($bean->field_name_map['state'], true));
        if($bean->state == 'Closed'){
           $bean->field_name_map['resolution'] += array('required' => 1);
           $GLOBALS['log']->debug('show--> ' . print_r($bean->field_name_map['resolution'], true));
           //include('custom/Extension/modules/Cases/Ext/Vardefs/resolution_required.php');
           $GLOBALS['log']->debug('inside_statement');

        }
       

        
    }
}                       
The administrator has disabled public write access.

required fields 6 days 9 hours ago #69204

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 6868
  • Thank you received: 1048
  • Karma: 244
I now understand better what you're trying to do.

I believe you have to change your approach. You can't make it required in the vardefs, or in the dictionary, since those things take effect on screens, and the logic hook is not running on a screen.

Normally this kind of thing is done by overriding the display class of the view you want to change. And there you can inject some javascript to react to changes and give some user feedback to make the field required.

Google for stuff related to overriding views, validating fields, etc.

Maybe this one will be helpful
suitecrm.com/suitecrm/forum/developer-he...-viewedit-validation
Last Edit: 6 days 7 hours ago by pgr.
The administrator has disabled public write access.

required fields 6 days 8 hours ago #69206

  • JorgeT
  • JorgeT's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
Thank you, I will
The administrator has disabled public write access.
Time to create page: 0.107 seconds
Powered by Kunena Forum