How to customize dropdown items depend on the user security group?

Hello,

I am newbie  to suger Crm , I am wondering how can I customize the sales stage drop down in opportunity model for example , so if user A from the security group SALES1 can see only the 3 options (Prospecting, Qualification, Needs Analysis) , if another users (user B) from security group SALES2 can see the whole list.

Thank you,

Hafez

Parents
  • Hi hafez Ahmad

    Already there is the Correct Answer for it.

    Once check this post and let me know for further help.

    Here on line 9 we are getting current user role and checking, instead change the code to group.

    you can get by:

    app.user.get('<fieldname>');

    In ./custom/modules/Opportunities/clients/base/views/create/create.js

     
    ({
       extendsFrom: 'CreateView',
       initialize: function (options) {
             this._super('initialize', [options]);
             this.restrictSalesStages();
       },
       restrictSalesStages: function() {
          if(app.user.get('type') != 'admin') {
             //getting all the options key:value fom sales_stage_dom
             var sale_stage_list = app.lang.getAppListStrings('sales_stage_dom');
             Object.keys(sale_stage_list).forEach(function(key) {
                var check = sale_stage_list[key].match(/Investment/);
                if(check) {
                   delete sale_stage_list[key]; //deleting 'Investment' key from the list
                }
             });
          }
       this.model.fields['sales_stage'].options = sale_stage_list;
    },
    _dispose: function() {
      
          this._super('_dispose');
    },
    });

    We can replicate the same to record.js for edit view.

    It is tested and successfully working in my Sugarcrm 7.7.1.1 Pro instance

    Best Regards

    S Ramana Raju

Reply
  • Hi hafez Ahmad

    Already there is the Correct Answer for it.

    Once check this post and let me know for further help.

    Here on line 9 we are getting current user role and checking, instead change the code to group.

    you can get by:

    app.user.get('<fieldname>');

    In ./custom/modules/Opportunities/clients/base/views/create/create.js

     
    ({
       extendsFrom: 'CreateView',
       initialize: function (options) {
             this._super('initialize', [options]);
             this.restrictSalesStages();
       },
       restrictSalesStages: function() {
          if(app.user.get('type') != 'admin') {
             //getting all the options key:value fom sales_stage_dom
             var sale_stage_list = app.lang.getAppListStrings('sales_stage_dom');
             Object.keys(sale_stage_list).forEach(function(key) {
                var check = sale_stage_list[key].match(/Investment/);
                if(check) {
                   delete sale_stage_list[key]; //deleting 'Investment' key from the list
                }
             });
          }
       this.model.fields['sales_stage'].options = sale_stage_list;
    },
    _dispose: function() {
      
          this._super('_dispose');
    },
    });

    We can replicate the same to record.js for edit view.

    It is tested and successfully working in my Sugarcrm 7.7.1.1 Pro instance

    Best Regards

    S Ramana Raju

Children
No Data