Can you default the Assigned To of a Case to a blank value?

Upon creating a new case, can the Assigned To be default to a blank value?  The field would be required inducing the user to populate the Assigned To in order to save.  There is a common use case in which the user saving the Case forgets to change the Assigned To which defaults to their own personal user. 

  • I will write up the entire upgrade-proof version soon, but here is the down and dirty fix:

    Just comment out the last line I show here

    [NOTE: this is CE 6.5.22 and about line 180 in modules/Cases/Case.php]

      function fill_in_additional_detail_fields()

      {

      parent::fill_in_additional_detail_fields();

      // Fill in the assigned_user_name

      $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);

  • For an upgrade-proof version you first need to create the path: /custom/modules/Cases/

    In that folder create a controller.php that contains this code:

    <?php

    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    //this file is custom/modules/Cases/controller.php

    require_once('include/MVC/Controller/SugarController.php');

    require_once('custom/modules/Cases/CustomCase.php');

    class CustomCasesController extends SugarController

    {

      public function loadBean()

      {

            $this->bean = new CustomCase();

            if(!empty($this->record))

            {

                $this->bean->retrieve($this->record);

                if($this->bean)

                    $GLOBALS['FOCUS'] = $this->bean;

            }

       }

    }

    Then create the file custom/modules/Cases/CustomCase.php that has this contents:

    <?php

    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    // this file is /custom/modules/Cases/CustomCase.php

    require ( 'modules/Cases/Case.php' );

    class CustomCase extends Case

    {

    function fill_in_additional_detail_fields()

    {

    parent::fill_in_additional_detail_fields();

    $this->created_by_name = get_assigned_user_name($this->created_by);

    $this->modified_by_name = get_assigned_user_name($this->modified_user_id);

    if(!empty($this->id))

    {

      $account_info = $this->getAccount($this->id);

      if(!empty($account_info)) {

      $this->account_name = $account_info['account_name'];

      $this->account_id = $account_info['account_id'];

    }

    }


    }

    That should do it. You will be upgrade-proof. Just don't forget to Repair just to be safe.

    I have done some similar things, but not this exact customization, so let me know how it works for you.

  • Oops, I see that this won't work since you are calling the parent which would add that value in the field that you want to keep blank. Thus, try adding this line of code right below the parent call

    $this->assigned_user_name = '';

  • Hi Jon Parmley,

    create a file in /custom/Extension/modules/Cases/Ext/Vardefs/sugarfield_assigned_to.php

    and pass argument 'default' to null and 'required' to true like below,

    /custom/Extension/modules/Cases/Ext/Vardefs/sugarfield_assigned_user_id.php

    <?php

    $dictionary['Case']['fields']['assigned_user_id']['default']='';

    $dictionary['Case']['fields']['assigned_user_id']['required']=true;

    ?>

    and repair and rebuild.Now your assigned_to will be blank with required.

    Thanks!.

  • Ajay,

    Thanks for this reply. I remember seeing it somewhere else before and it is much more elegant than the hack that I suggested.

  • It worked fine.. and its getting empty but how to give a default user for this field

  • Hi Ash,

    Try putting a user ID between the single quotes in:

    $dictionary['Case']['fields']['assigned_user_id']['default']='';
  • yes i have tried but its getting logged in user's name only not changing the user..