Need to hide Help & Training Option/Icon in lightning for specific Profile.please find the attached screenshot for better understanding.
1 Answer
There is no configurable way to achieve this.
However, you can have a blank UI lightning component placed in the home page of the org. The lightning component will hide the help link from the top.
The solution is: The question mark link for help that you see is under a div with a class name - oneHelpAndTrainingExperience
. So our aim should be to search for the div with class name oneHelpAndTrainingExperience
and hide it.
Lightning Component:
<aura:component controller="OrgUtilities" implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<!--Its a blank UI component-->
</aura:component>
JS controller:
({
doInit : function(component, event, helper) {
var action = component.get('c.isHelpHidden');
action.setCallback(this, function(response){
if(response.getState() === 'SUCCESS')
{
if(response.getReturnValue() == true)
{
var elements = document.getElementsByClassName('oneHelpAndTrainingExperience');
elements[0].style.display = 'none';
}
}
});
$A.enqueueAction(action);
}
})
Apex class:
public class OrgUtilities {
@AuraEnabled
public static Boolean isHelpHidden()
{
List<String> profileNames = new List<String>();
/*fill up profileNames list with the profile names for which you want the help link to hide*/
List<Profile> profileList = [Select Id from Profile where Name IN :profileNames and Id = :UserInfo.getProfileId()];
if(profileList != null && profileList.size() > 0)
{
return true;
}
else
{
return false;
}
}
}
Why Lightning component instead of VF? Any VF page that you use comes from a domain visual.force.com
, but Lightning experience opens on lightning.force.com
, so if you try to search for a div of lightning.force.com
domain using a script in visual.force.com
, Cross-site scripting occurs and it fails. So lightning component are the way out.