required fields

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?

Hi! These Forums are for SuiteCRM, not SugarCRM…

Thanks for your replay, any advice for suiteCRM 7.8?

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?

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');   


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));



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

Thank you, I will