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

  • Hello Everyone,

    This development is work for the Mobile App ?

    Because I have check this code in to my development instance but in mobile-app that is not working.

    Shijin KrishnaMatt MarumAlan BeamGaelle Fernandez

Reply Children
  • Hi Bavesh,

    Current implementation of Sugar Mobile App won't support custom js like record.js, create-action.js etc.

  • Hello shijin Krishna,

    Does any way there I  can restrict record's creation using mobile app.

  • You would have to attempt to restrict it from Mobile REST APIs.  You could update User APIs to return ACLs that restrict 'create' action for modules you do not want the user to be able to create on Mobile.  Sidecar clients (like Mobile) obey a 'create' ACL that is not yet supported in backend.  I haven't experimented with this yet, so I couldn't say for sure how well it would work. But what I have in mind would not require a lot of code changes.

    See this blog post for example of how you can override REST API endpoints for Mobile clients.  In this case, you would want to override the API that returns client side ACLs to include additional ACL rules.

    Using server side changes to customize SugarCRM Mobile « Sugar Developer Blog – SugarCRM

    App Ecosystem @ SugarCRM

  • Hey I got the solution for mobile app Disable record's creation below is the link where  I have share my code.
    How to restrict Account Create In to Mobile-App sugarCRM 7.* ?

  • Hello Everyone,

    I got it working really well, as described by Gaelle.

    I wonder if it is possible to set custom acls e.g. acls.Opportunities.customButton= 'no';

    and to use it together with custom buttons/links e.g. /custum/modules/Opportunities/clients/base/record/record.php:

    <?php
    $viewdefs['Opportunities'] = 
    array (
      'base' => 
      array (
        'view' => 
        array (
          'record' => 
          array (
            'buttons' => 
            array (
              0 => 
              array (
                'type' => 'button',
                'name' => 'cancel_button',
                'label' => 'LBL_CANCEL_BUTTON_LABEL',
                'css_class' => 'btn-invisible btn-link',
                'showOn' => 'edit',
              ),
              1 => 
              array (
                'type' => 'rowaction',
                'event' => 'button:save_button:click',
                'name' => 'save_button',
                'label' => 'LBL_SAVE_BUTTON_LABEL',
                'css_class' => 'btn btn-primary',
                'showOn' => 'edit',
                'acl_action' => 'edit',
              ),
              2 => 
              array (
                'type' => 'actiondropdown',
                'name' => 'main_dropdown',
                'primary' => true,
                'showOn' => 'view',
                'buttons' => 
                array (
                  0 => 
                  array (
                    'type' => 'rowaction',
                    'event' => 'button:edit_button:click',
                    'name' => 'edit_button',
                    'label' => 'LBL_EDIT_BUTTON_LABEL',
                    'acl_action' => 'edit',
                  ),
                  1 => 
                  array (
                    'type' => 'rowaction',
                    'event' => 'button:create_platformaccount:click',
                    'name' => 'create_platformaccount',
                    'css_class' => 'create_platformaccount',
                    'label' => 'LBL_CONVERT_BUTTON_LABEL',
                    'acl_action' => 'customButton',
                  ),
                   ...
    

    What do you think?

  • Just answering my own question above. After some tests, it seems to work.