Announcement

Collapse
No announcement yet.

Is there anyway to NOT ALLOW a user from changing their preferences ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is there anyway to NOT ALLOW a user from changing their preferences ?

    issue we are having is that we rely on CRM notification both in App and email notification to keep our users informed, however we have noticed that some of our users were not engaged and when we checked we found that they have disabled the notifications on the CRM and hence they don't receive any further notifications. is there any way to NOT ALLOW the user to change their notification setting ?

    Thanks
    Rabii
    Web Dev

  • #2
    Hi Rabii, would hiding the drop-down option be enough?

    I do remember there was a topic about this

    Comment


    • #3
      No i need to hide only preference, only way is a custom navbar so i am working on it now i just thought maybe i am missing a GUI config for that but turns out not possible through GUI
      Rabii
      Web Dev

      Comment


      • #4
        For interest I tried to get rid of these configurations. I copied the folder Preferences from application/Espo/Resources/layouts to the custom folder and in the file detail.json I deleted the lines on the bottom "name": "notifications", which hides that tab completely for everybody.

        I know, it is a bit a hard hack, but works.
        Last edited by shalmaxb; 07-04-2023, 03:12 PM.

        Comment


        • #5
          Hi,
          Maybe :

          application/Espo/Resources/metadata/scopes/Preferences.json
          PHP Code:

          {
              
          "entity"true,
              
          "layouts"false,
              
          "tab"false,
              
          "acl"false,
              
          "customizable"true <= change from false to true
          }​ 
          go to admin/entityManager/Preferences.. set field read only and default value.

          To test.

          Comment


          • rabii
            rabii commented
            Editing a comment
            I already tried that before didn't work, my purpose is to Not Allow user to disable notifications (all sort) the preferences entity doesn't have any ACL applied to it so therefore there is no way to disable a specific field for a user. I also tried customising the layout so i could hide only the preferences tab but no success hence there is way to check fi the user type is admin or regular.

        • #6
          Hi Rabii,
          of course if i have understand your request.

          custom record/edit i do if understand do the trick.
          of course you can check if user is admin or regular.

          PHP Code:
          define('custom:views/preferences/record/edit', ['views/preferences/record/edit'], function (Dep) {

              return 
          Dep.extend({

                  
          setup: function () {
                      
          Dep.prototype.setup.call(this);

                      
          hideNotificationPanel true;

                      if (
          hideNotificationPanel) {
                          
          //this.hidePanel('notifications');
                      
          }
                      
          this.setFieldReadOnly('assignmentNotificationsIgnoreEntityTypeList');

                  },
                  
                  
          afterRender: function () {
                      
          Dep.prototype.afterRender.call(this);
                  },
              });
          });
          ​ 

          Click image for larger version  Name:	Screenshot 2023-07-05 at 10.24.19.png Views:	0 Size:	43.3 KB ID:	95050

          Comment


          • rabii
            rabii commented
            Editing a comment
            thanks for sharing that is exactly what i did. i first went through customising the navbar and user view to hide the preferences from the menu but didn't like that then i thought customising the preferences would work and it worked.

          • shalmaxb
            shalmaxb commented
            Editing a comment
            rabii, hello,
            I currently have that same problem. Your solution in the following thread already helped, thank you.
            In this comment, you mention, that you customized the navbar to get rid of the preferences link. How did you do that. I tried a solution from another thread, which did not work.
            Perhaps you still have that code on hand, I thank you in advance.

        • #7
          Hey all,

          Thanks for your help and support, my use case was to hide notifications from the preference view to not allow regular user to disable them, after tinkering around i found a way around which does exactly what i want, below is what i did :

          1 - created a custom Preferences.json under custom directory (clientDefs) and defined a new custom edit view as below:

          PHP Code:
          {
             
          "recordViews":{
                
          "edit""custom:views/preferences/record/edit"
             
          }
          }
          ​ 

          2 - Create the custom view under client\custom\src\views\preferences\record\edit.js

          PHP Code:
          define('custom:views/preferences/record/edit', ['views/preferences/record/edit'], function (Dep) {

              return 
          Dep.extend({

                  
          setup: function () {
                      
          Dep.prototype.setup.call(this);

                      if (!
          this.getUser().isAdmin()) {
                          
          this.layoutName 'detailRegular';
                      }
                  },
              });
          });
          ​ 

          3 - As you can see in the code above i have simple condition to check if current user is not admin (means regular) then apply a detailRegular layout which i created as below:

          PHP Code:
          [
              {
                  
          "rows": [
                      [{
          "name""dateFormat"}, {"name""timeFormat"}],
                      [{
          "name""defaultCurrency"}, {"name""thousandSeparator"}],
                      [
          false, {"name""decimalMark"}]
                  ],
                  
          "tabBreak"true,
                  
          "tabLabel""$label:Locale"
              
          },
              {
                  
          "rows": [
                      [{
          "name""exportDelimiter"}, {"name":"autoFollowEntityTypeList"}],
                      [
                          {
                              
          "name""signature"
                          
          },
                          {
                              
          "name""defaultReminders"
                          
          }
                      ],
                      [
                          {
                              
          "name""emailReplyToAllByDefault"
                          
          },
                          {
                              
          "name""doNotFillAssignedUserIfNotRequired"
                          
          }
                      ],
                      [
                          {
                              
          "name""emailReplyForceHtml"
                          
          },
                          {
                              
          "name""followEntityOnStreamPost"
                          
          }
                      ],
                      [
                          {
                              
          "name""emailUseExternalClient"
                          
          },
                          {
                              
          "name""followCreatedEntities"
                          
          }
                      ],
                      [
                          {
                              
          "name""textSearchStoringDisabled"
                          
          },
                          {
                              
          "name""followCreatedEntityTypeList"
                          
          }
                      ]
                  ],
                  
          "tabBreak"true,
                  
          "tabLabel""$label:Misc"
              
          },
              {
                  
          "rows": [
                      [
                          {
          "name":"theme"},
                          
          false
                      
          ],
                      [
                          {
          "name":"useCustomTabList"},
                          {
          "name":"tabList"}
                      ],
                      [
                          {
          "name":"dashboardLayout""fullWidth"true}
                      ]
                  ],
                  
          "tabBreak"true,
                  
          "tabLabel""$label:User Interface"
              
          }
          ]
          ​ 

          That is it and it worked as i wanted, the good thing about this approach is its simplicity and also i get to design a whole layout which i can control what the regular user should see and not see.

          Hope this help someone when needed.

          Thanks again
          Last edited by rabii; 07-06-2023, 08:00 AM.
          Rabii
          Web Dev

          Comment


          • #8
            Maybe define a custom API route for PUT Preferences/:id that will throw Forbidden exception if logged not by admin. Otherwise, call service->update.

            Comment


            • rabii
              rabii commented
              Editing a comment
              thank you @yuri
              i have managed to create custom preference view that check if user is Regular then show a different layout and it works. i will check your solution though to see how it is different.

          • #9
            Hey shalmaxb

            Yes that was my first solution which was to remove the preference from the menu on the top right. and below what i have done to achieve it (Remember this will only hide it from the UI) however if a user know the url for preference they would still be able to access. Also this was done on previous version not sure it is impacted with the new version, anyway try it out and see how it goes.


            1 - Create App.json under custom\Espo\Custom\Resources\metadata\clientDefs
            PHP Code:
            {
                
            "navbarView" "custom:views/site/navbar"
            }​ 


            2 - Create the new custom view navbar.js under client\custom\src\views\site
            PHP Code:
            define('custom:views/site/navbar', ['views/site/navbar'], function (Dep) {

                return 
            Dep.extend({

                    
            getMenuDataList: function () {

                        var list = 
            Dep.prototype.getMenuDataList.call(this);

                        if (!
            this.getUser().isAdmin()) {
                            list = list.
            filter(item => item.link !== '#Preferences');
                        }
                        
                        return list;
                    },
                });

            });
            ​ 

            I hope this helps
            Rabii
            Web Dev

            Comment


            • rabii
              rabii commented
              Editing a comment
              glad it still works thanks for your word mate

            • nunos
              nunos commented
              Editing a comment
              Hi rabii, just tried the above solution but not working... blank screen and nothing happens... using version 8.1.1.
              Any workaround?

              Update: it's working! i was doing something wrong... just works perfect!!! thanks!
              Last edited by nunos; 05-24-2024, 09:42 PM.

            • rabii
              rabii commented
              Editing a comment
              sorry i have just seen your message nunos. I am glad it is working now, if you face any issues feel free to reach out
          Working...
          X