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

  • HI Shijin !

    Again, thanks a lot, i think yesterday i wasn't fully aware.
    So, i've erased every reference to your module in my code. My custom Api is set under custom/clients/base/api.

    But i still can't get my user role.
    I've added a little 
    $GLOBALS['log']->error('User roles :'.$user_roles);
    in my getCurrentUserRoleApi.php before the return $user_roles, but my log (set in Error Level) does not show anything.

    The api is well included and interprted as an api, because when testing in http://<sugar>/rest/v10/help , i have the GET userRole.

    I've tested the url : http://<sugar>/rest/v10/userRole , and it returned an error message : 
    {"error":"need_login","error_message":"No valid authentification for user."}

    So maybe i should add a curl call before, to add the credentials?

    i'm browsing the internet to try to understand what is wrong, but that is kind of tough, because my knowledges in Webservices and api calls are limitfull ...

    So thanks again to share your knowledges ! :)
Reply
  • HI Shijin !

    Again, thanks a lot, i think yesterday i wasn't fully aware.
    So, i've erased every reference to your module in my code. My custom Api is set under custom/clients/base/api.

    But i still can't get my user role.
    I've added a little 
    $GLOBALS['log']->error('User roles :'.$user_roles);
    in my getCurrentUserRoleApi.php before the return $user_roles, but my log (set in Error Level) does not show anything.

    The api is well included and interprted as an api, because when testing in http://<sugar>/rest/v10/help , i have the GET userRole.

    I've tested the url : http://<sugar>/rest/v10/userRole , and it returned an error message : 
    {"error":"need_login","error_message":"No valid authentification for user."}

    So maybe i should add a curl call before, to add the credentials?

    i'm browsing the internet to try to understand what is wrong, but that is kind of tough, because my knowledges in Webservices and api calls are limitfull ...

    So thanks again to share your knowledges ! :)
Children
No Data