AnsweredAssumed Answered

How to hide panel in SugarCRM 7.9 ?

Question asked by Lokesh Bhandari on Apr 9, 2019
Latest reply on Apr 9, 2019 by Junaid Usman

(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;
}

}

Outcomes