Disable record's creation

Hello everybody !

I have a really urgent problem to solve :

How can i disable the "creation" of new records (in standdard modules like Accounts, but in custom too) for few users?

I was thinking about roles, but there is nothing on the role management.
I would like to disable the creation of new Accounts for the role "lambda user".

of course, we have to take care of disable "duplication" too.

By disable, i mean, disallowed access to the button "create" and "duplicate" and to disallowed the action.

Do you know how to disable the action of creation/duplication and how to hide the "create"/"duplicate" buttons ?

Thanks a lot !

ps : Im on Sugar 7.5.1 Pro
Parents
  • Hi GaelleFernandez

    You can set access for Edit to none in roles management for Accounts module for this particular role.
    Then users come under that role won't be able to edit,create or duplicate an account

    Thanks!
  • Creation of records is governed by the "Edit" ACL on backend.  So you need to do some customizations in order to disable Create actions but not Edit actions.  However, on the front end, we've already started adding some support for a "Create" ACL.  You can modify the User's ACLs object to utilize this.  Or you could override the /me API endpoint that returns the User's ACLs to include additional "create" permissions for any "lambda user".

    Try this in your browser.
    var acls = SUGAR.App.user.getAcls();
    acls.Accounts.create = 'no';
    SUGAR.App.user.set("acls", acls);
    And then navigate away and then back to Accounts module to force a re-render.  The "Create" button at the top will disappear and if you navigate into an Account record you will find the "Copy" or "Duplicate" buttons no longer appear in action dropdown.

    Of course, you can always just manipulate DOM directly.  For example, if you could add CSS "disabled" class to these buttons which will disable them visually and then remove any jQuery event listeners that might be on these elements to prevent actions from being triggered.  Or just remove these elements all together.

    App Ecosystem @ SugarCRM

  • Try changing this line:
    app.user.set("acl", acls);
    Note the change from "acls" to "acl". This fixed the issue for me. However, I also noticed that when you use the API call, the delay to make that call results in the Create button being rendered before this code is run. If the user then clicks on Create, they'll get an error message and subsequent loads of the List View will omit the Create button. Reloading the page will start that process over. Just something worth keeping in mind.
Reply
  • Try changing this line:
    app.user.set("acl", acls);
    Note the change from "acls" to "acl". This fixed the issue for me. However, I also noticed that when you use the API call, the delay to make that call results in the Create button being rendered before this code is run. If the user then clicks on Create, they'll get an error message and subsequent loads of the List View will omit the Create button. Reloading the page will start that process over. Just something worth keeping in mind.
Children
No Data