How to hide panel in SugarCRM 7.9 ?

(Scenario 1) :- I want to hide panel in SugarCRM on based on user's department. If user's department is Accountant then I want to show subpanel and if not Accountant then I want to hide this panel. For this I have refer document 

https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Architecture/Sugar_Logic/Dependency… 

But this is working on Account module field only. User's Module field (department) is not working on Account module. 

(Scenario 2) :- So I have decide to do this with js file

For that I have created file custom/modules/Accounts/clients/base/views/record/record.js and in this

({

extendsFrom: 'RecordView',

zipJSON: {},

initialize: function (options) {
this._super('initialize', [options]);
this.model.on('sync', this.showhidetallypanel, this);
},

showhidetallypanel: function() {
console.log("showhidetallypanel is called");
$.ajax(
{
url: 'rest/v10/TallyConnector/Tally_Panel_Show_Hide',
type: 'POST',
success: function(get_body)
{
if(get_body==true)
{
$('div[data-panelname="LBL_RECORDVIEW_PANEL1"]').show();
}
else
{
$('div[data-panelname="LBL_RECORDVIEW_PANEL1"]').hide();
}
}
});
},
})

And then Created End Point  Tally_Panel_Show_Hide.php But with noLoginRequiredgin false it is not working. Endpoint is not called with noLoginRequiredgin false method

<?php

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class Tally_Panel_Show_Hide extends SugarApi
{
public function registerApiRest()
{
return array(
'Tally_Panel_Show_Hide' => array(
'reqType' => array('GET','POST'),
'noLoginRequired' => false,
'path' => array('TallyConnector', 'Tally_Panel_Show_Hide'),
'pathVars' => array('',''),
'method' => 'tally_panel',
'shortHelp' => 'Tally Panel Show Hide',
'longHelp' => 'custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html',
),
);
}

public function tally_panel($api, $args)
{
global $current_user;
$GLOBALS['log']->fatal("tally panel is called {$current_user->id}");
$department = $current_user->department;
//
return false;
}

}

  • Hi Lokesh Bhandari,

    You don't need an extra API call to get the information of the current user department. You can use the js create bean function to fetch the current user department information. Following is the small snippet as an example.

    var userBean = app.data.createBean('Users', {id: app.user.id});
    var request = userBean.fetch({
    success: function(){
    /* do stuff */
    },
    error: function(){
    /* do stuff */
    }
    });

    Happy Coding

    Regards,

    Junaid