Can a logic hook invoke admin rights?

The Assigned To field in our clients module is set to Read Only for the sales agent role because we don't want the agents to be able to change that field at all.  What I need to do is find a way during the creation of a new client to run a hook - or part of a hook - as the admin user to set the Assigned To field to the agent creating the new client.  Is this possible?

Thanks.

Jason

Parents
  • You might want to consider approaching the problem a slightly different way.

    Given that the creation screen is controlled by a different view than the one for the edit/view screen (Create vs. Record), you could leave the Assigned To field as editable, then modify the metadata for the RecordView to set that same field as readonly. That would allow the user to set an Assigned To value on creation, but not edit it after the fact.

  • Thanks, Angel.  Sorry for taking so long to get back to you.  I thought the answer would be something like this.  Would you be able to provide a little more direction, or point me to where I can find information on doing this?

    Jason

  • No problem.

    There are about 3 - 4 different ways to do this, but perhaps the easiest and least intrusive would be to simply create a custom controller for your RecordView.

    Create a file called record.js and put the following code in it:

    ({
      extendsFrom: 'RecordView',
    
      initialize: function(options){
      this._super('initialize', [options]);
      this.model.fields['assigned_user_name']['readonly'] = true;
      }
    
    })
    

    Save the file to ./custom/modules/Accounts/clients/base/views/record/, purge the contents of ./cache and reload Sugar. That should do it.

Reply
  • No problem.

    There are about 3 - 4 different ways to do this, but perhaps the easiest and least intrusive would be to simply create a custom controller for your RecordView.

    Create a file called record.js and put the following code in it:

    ({
      extendsFrom: 'RecordView',
    
      initialize: function(options){
      this._super('initialize', [options]);
      this.model.fields['assigned_user_name']['readonly'] = true;
      }
    
    })
    

    Save the file to ./custom/modules/Accounts/clients/base/views/record/, purge the contents of ./cache and reload Sugar. That should do it.

Children