Remove knowledge base from portal

Rishi32
Tera Contributor

Hi All,

We need to remove knowledge base from portal based on company, for example company A and company B, if the user from company A, he could be able to see the knowledge base, if the user from company B, we need to hide knowledge base for them, could you please help on this to achieve.

 

Thanks in Advance!!

 

1 ACCEPTED SOLUTION

@Rishi32 then you might have to clone the ICON link widget to do this because the widget that you are seeing is OOB which is called as ICON link where you can put conditions as the code is not editable .

So you need to clone that widget and replace your cloned widget in your homepage and then code in the server script accordingly by getting the logged in users company and then hide it for company B users 

 

steps:

1) Go to widget table and then open icon link widget 

Screenshot 2022-11-14 at 12.49.51.png

 

2) Open the icon link widget and hit clone widget button

Screenshot 2022-11-14 at 12.50.06.png 

 

3) Then you need to write the below script in HTML and server part to get the logged in user company and then hide it if its comp B 

<div ng-if="data.compB==false"> <!--added this line to check if its compb-->
<div class="iconlink" ng-class="{'high-contrast': accessibilityModeEnabled}">
  <!--// Top Icon -->
  <a ng-if="::(options.link_template == 'Top Icon' || !options.link_template)" ng-href="{{::data.href}}" class="top_icon {{::options.class_name}}" target="{{::data.target}}">
    <div class="m-b fa fa-{{::options.glyph}} fa-4x {{::options.class_name}} text-{{::options.color}}"></div>
    <h2>{{::options.title}}</h2>
    <span class="text-muted">{{::options.short_description}}</span>
  </a>

  <!--// Circle Icon -->
  <a ng-if="::(options.link_template == 'Circle Icon')" ng-href="{{::data.href}}" class="circle_icon {{::options.class_name}} text-{{::options.color}}" target="{{::data.target}}">
    <span class="fa fa-stack fa-2x" aria-hidden="true">
      <i class="fa fa-circle fa-stack-2x"></i>
      <i class="fa fa-{{::options.glyph}} fa-stack-1x fa-inverse"></i>
    </span>
    <h2>{{::options.title}}</h2>
    <span class="text-muted">{{::options.short_description}}</span>
  </a>

  <!--// Color Box -->
  <a ng-if="::(options.link_template == 'Color Box')" ng-href="{{::data.href}}" class="color_box {{::options.class_name}} icon-link-background-{{::options.color}} text-white" target="{{::data.target}}">
    <div class="fa fa-{{::options.glyph}} fa-3x {{::options.class_name}}"></div>
    <h2>{{::options.title}}</h2>
    <span>{{::options.short_description}}</span>
  </a>
</div>
</div><!--added this line to check if its compb-->

In the above HTML code i have added first line and last line to the cloned widget 

Server script :

(function(){
	var gr = $sp.getInstanceRecord();
	data.href = $sp.getMenuHREF(gr);
	data.target = options.target || "";
	
	var companyID = gs.getUser().getCompanyID();
	data.compB=false;
	if(companyID=="your company b sys_id")
		{
			data.compB=true;
		}

})();

You can paste the above server script 

 

4)Then open your homepage and replace your cloned widget in place of knowledge base widget like below 

Open your home page which i am assuming as "index " page and then click on instance with link on knowledge base as highlighted below

Screenshot 2022-11-14 at 12.58.31.png

 

5) then after opening the record replace your cloned widget in widget column 

Screenshot 2022-11-14 at 13.00.13.png

 

Hope this helps 

 

Mark the answer correct if this helps you

 

Thanks

 

View solution in original post

7 REPLIES 7

Rishi32
Tera Contributor

Rishi32_0-1668409177700.png

Please find the attachment

@Rishi32 Hello,

 

You need to hide the the knowledge base icon completely for Company B users ?

Hi Mohith,

Yes, We need to hide knowledge base completely for company B users

@Rishi32 then you might have to clone the ICON link widget to do this because the widget that you are seeing is OOB which is called as ICON link where you can put conditions as the code is not editable .

So you need to clone that widget and replace your cloned widget in your homepage and then code in the server script accordingly by getting the logged in users company and then hide it for company B users 

 

steps:

1) Go to widget table and then open icon link widget 

Screenshot 2022-11-14 at 12.49.51.png

 

2) Open the icon link widget and hit clone widget button

Screenshot 2022-11-14 at 12.50.06.png 

 

3) Then you need to write the below script in HTML and server part to get the logged in user company and then hide it if its comp B 

<div ng-if="data.compB==false"> <!--added this line to check if its compb-->
<div class="iconlink" ng-class="{'high-contrast': accessibilityModeEnabled}">
  <!--// Top Icon -->
  <a ng-if="::(options.link_template == 'Top Icon' || !options.link_template)" ng-href="{{::data.href}}" class="top_icon {{::options.class_name}}" target="{{::data.target}}">
    <div class="m-b fa fa-{{::options.glyph}} fa-4x {{::options.class_name}} text-{{::options.color}}"></div>
    <h2>{{::options.title}}</h2>
    <span class="text-muted">{{::options.short_description}}</span>
  </a>

  <!--// Circle Icon -->
  <a ng-if="::(options.link_template == 'Circle Icon')" ng-href="{{::data.href}}" class="circle_icon {{::options.class_name}} text-{{::options.color}}" target="{{::data.target}}">
    <span class="fa fa-stack fa-2x" aria-hidden="true">
      <i class="fa fa-circle fa-stack-2x"></i>
      <i class="fa fa-{{::options.glyph}} fa-stack-1x fa-inverse"></i>
    </span>
    <h2>{{::options.title}}</h2>
    <span class="text-muted">{{::options.short_description}}</span>
  </a>

  <!--// Color Box -->
  <a ng-if="::(options.link_template == 'Color Box')" ng-href="{{::data.href}}" class="color_box {{::options.class_name}} icon-link-background-{{::options.color}} text-white" target="{{::data.target}}">
    <div class="fa fa-{{::options.glyph}} fa-3x {{::options.class_name}}"></div>
    <h2>{{::options.title}}</h2>
    <span>{{::options.short_description}}</span>
  </a>
</div>
</div><!--added this line to check if its compb-->

In the above HTML code i have added first line and last line to the cloned widget 

Server script :

(function(){
	var gr = $sp.getInstanceRecord();
	data.href = $sp.getMenuHREF(gr);
	data.target = options.target || "";
	
	var companyID = gs.getUser().getCompanyID();
	data.compB=false;
	if(companyID=="your company b sys_id")
		{
			data.compB=true;
		}

})();

You can paste the above server script 

 

4)Then open your homepage and replace your cloned widget in place of knowledge base widget like below 

Open your home page which i am assuming as "index " page and then click on instance with link on knowledge base as highlighted below

Screenshot 2022-11-14 at 12.58.31.png

 

5) then after opening the record replace your cloned widget in widget column 

Screenshot 2022-11-14 at 13.00.13.png

 

Hope this helps 

 

Mark the answer correct if this helps you

 

Thanks