by eggsurplus

Control what your users can access and save time, money, and frustrations. Lock down sensitive data in SugarCRM or SuiteCRM to specific groups or teams. Supports unlimited assigned users, unlimited group assignments to records, custom layouts for each group, login/sudo capabilities and much more.

Free 30 day trial
Try it Now

#2463 - Run-time switching between group views of custom modules

In Progress General Question created by Jawad Zafar 3 years ago

Hi,
I have a user with multiple groups and for each group, I have different views setup for my custom modules. I need to switch between edit views on page load using specific criteria. Can I accomplish this requirement?

  1. eggsurplus member avatar

    eggsurplus Provider Affiliate

    3 years ago

    Yes, but it will take a little work. Within include/MVC/Views are all the major views. If you open view.edit.php look inside the preDisplay() function. This is how it determines which layout to show the user. The best approach for your custom module is to have a view.edit.php and override the preDisplay() to add your logic.

    Hope that helps!

  2. ccenter member avatar

    Jawad Zafar

    3 years ago

    Thanks for quick reply. I was thinking of doing it with some other way as I don't want to edit all views for all modules (a lot of time and work). Is it possible that I can change the default group to be considered for opening views? I actually have a scenario where if the user selects a group, for a specific time (I'm using core PHP sessions - $_SESSION to handle this), it starts to show all views related to that department only. Like, if a user selects group A after login, he can only view all views of all custom modules related to group A. If he selects group B at a later time, he can only see all views related to group B for all custom modules.

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      3 years ago

      It looks like you can just set the group ID in $_SESSION['groupLayout'] and it should work.

    • ccenter member avatar

      Jawad Zafar

      3 years ago

      Thanks for the tip. Just a little thing remaining. Its working for detail view. But its not working for sub panels. Any hint regarding that?

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      3 years ago

      Custom group subpanels aren't supported by SecuritySuite. Anything relating to that will be something in the /include/SubPanel and /include/ListView directories.

    • ccenter member avatar

      Jawad Zafar

      3 years ago

      Sorry for the mistake. I wanted to refer to QuickCreate view.

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      3 years ago

      I'll look into that. Quick peek tells me that the SecuritySuite code required to make that work isn't there. What version of SugarCRM or SuiteCRM are you on?

    • ccenter member avatar

      Jawad Zafar

      3 years ago

      I'm using SugarCRM CE Version 6.5.24 (Build 509)

  3. ccenter member avatar

    Jawad Zafar

    3 years ago

    And please clarify one thing. Does this $_SESSION['groupLayout'] renews its value on every page load? If yes, where I can put the code to make it work until I change it manually?

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      3 years ago

      Every page load. It just needs to be set before the view loads. It will take some playing around to find the right place for you based on however you handle that logic. It may need to be a hard coded change or a logic hook: http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/Logic_Hooks/Application_Hooks/

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      3 years ago

      Once it is set though it won't be unset. You will still want to likely set every page load to be safe.

    • ccenter member avatar

      Jawad Zafar

      3 years ago

      Basically I'm hitting a custom entry point and set $_SESSION['groupLayout'] to the value I pass in entry point. . After which the first page load works totally fine. But when I refresh it, or use sub-panel quick create, my stored value doesn't seem to work anymore.

    • ccenter member avatar

      Jawad Zafar

      3 years ago

      Just found the issue. I just needed to remove unset($_SESSION['groupLayout']); **under \include\TemplateHandler\TemplateHandler.php**

      Do guide me if you can help regarding one last issue. I now only face this value being destroyed whenever I open any list view.

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      3 years ago

      I'd advise just commenting out that unset for your needs or always set it before every view change. Not much else that can be done from what I can see.

    • ccenter member avatar

      Jawad Zafar

      3 years ago

      Thanks for your help. Setting variables in TemplateHandler constructor does the job for me. Thanks again for your help.

This case is public. Please leave out any sensitive information such as URLs, passwords, etc.
Saving Comment Saving Comment...
Rating
Rating
  • "I can say that it has been one of the best modules within our SugarCRM CE instance!"

    Read More Reviews

Keep up to date on the latest additions

We'll send you an email every month with handpicked add-ons, reviews, tricks and tips. Don't worry, we hate spam as much as you do.