开发者

SugarCRM: Custom Module assigned_to_user field not saving 'id' value

开发者 https://www.devze.com 2023-02-05 10:58 出处:网络
I\'m designing a Custom Module named Agents, using ModuleBuilder in SugarCE 6.0.0. The module is based on Accounts. In Studio, when I click on assigned_user_name from the Assignable section and save

I'm designing a Custom Module named Agents, using ModuleBuilder in SugarCE 6.0.0.

The module is based on Accounts. In Studio, when I click on assigned_user_name from the Assignable section and save it, it generates two fields, namely:

  • assigned_user_name
  • _id_c

When I deployed the package and tried to pick a username from the assigned to field, at first it wouldn't fetch any results at all (neither through autofill nor popup).

I checked out the custom/modulebuilder/packages/MyPackage/modules/Agents/vardefs.php, here's what I found:

'_id_c' => 
array (
  'required' => false,
  'name' => '_id_c',
  'vname' => '',
  'type' => 'id',
  'massupdate' => 0,
  'comments' => '',
  'help' => '',    
  'importable' => 'true',
  'duplicate_merge' => 'disabled',
  'duplicate_merge_dom_value' => 0,
  'audited' => false,
  'reportable' => true,
  'len' => 36,
  'size' => '20',
),
'assigned_user_name' => 
array (
  'required' => true,
  'name' => 'assigned_user_name',
  'link' => 'assigned_user_link',
  'vname' => 'LBL_ASSIGNED_TO_NAME',
  'rname' => 'name',
  'type' => 'relate',
  'reportable' => true,
  'source' => 'non-db',
  'table' => 'users',
  'id_name' => '_id_c',
  'module' => '',
  'duplicate_merge' => 'disabled',
  'massupdate' => 0,
  'comments' => '',
  'help' => '',
  'importable' => 'true',
  'duplicate_merge_dom_value' => '0',
  'audited' => true,
  'len' => '255',
  'size' =&开发者_如何学编程gt; '20',
  'ext2' => '',
  'quicksearch' => 'enabled',
  'studio' => 'visible',
),

Note that the module option in assigned_user_name is not being set to the right value. First question: Is this a Studio bug?

My quick fix was to set module => 'Users' and it worked. I was now able to select the username from a dropdown (autofill) list.

However, selecting a username still doesn't populate the hidden _id_c field with the 36 Char UUID of the user and hence, when I save the record and reload it, the assigned_user_name field remains blank.

Does anyone have an idea as to why this is happening? And any remedies for this?

Thanks,

m^e


Well don't think you should be getting these in your vardefs because these fields are defined in parent class which all modules extend. By default these are the fields that are user for assigned user:

var $assigned_user_id;
var $assigned_user_name;
var $assigned_user_link;

By looking at your code you can try setting:

'id_name' => 'assigned_user_id'

You are not supposed to create additional field for this field (_id_c).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号