phpsugarcrmsugarbean

sugarcrm display field in editview based on value in user details


I am trying to display a field in editview alone based on a fieldvale in userdetails.

Ex: For an user can_add_no will be in user details, if it is checked than that particular user can add a quote_extra_no in quote module.

I tried the following. Added dependency for the quote module for the field.

$dictionary['Quote']['fields']['quote_extra_no'] = array (
    'audited'                   => true,
    'calculated'                => false,
    'duplicate_merge'           => 'disabled',
    'duplicate_merge_dom_value' => '0',
    'importable'                => 'true',
    'len'                       => '255',
    'massupdate'                => false,
    'merge_filter'              => 'disabled',
    'name'                      => 'quote_extra_no',
    'no_default'                => true,
    'reportable'                => true,
    'required'                  => false,
    'size'                      => '50',
    'source'                    => 'custom_fields',
    'studio'                    => 'visible',
    'type'                      => 'varchar',
    'unified_search'            => false,
    'vname'                     => 'LBL_EXTRA_REF',
    'dependency'                => 'equal(related($assigned_user_link,"can_add_no"),"1")',
);

Also added the field in Editview. But its not working. If the current user can_add_no is set or checkbox is ticked. He can Edit the quote_extra_no in the editview of the quote.

How can i achive the functionality as the dependency is not helping me to do it.


Solution

  • There are two may to do that for both way you should have relation between both module.

    1. By Using Dependency :

      equal(related($related_field_name,"can_add_no"),"1")'

    2. IN record.js write a method in that method call a api for canadd_no and according to that show hide the field.

    API call Example :

      app.api.call('read', app.api.buildURL(this.model.get('_module'), 'read', {id: this.model.get('id')}), null,
                    {
                        success: function(data) {
                              your costume code to hide
                            }
                        },
                    });
    

    More Info related to API