Hide edit article option for specific knowledge base

v-paulp
Tera Contributor

Hi 

We have a requirement to hide the Edit article option  on the portal for specific knowledge base.

vpaulp_0-1715866071152.png

 

Also want to add a new option to action drop down list.

How can I achieve this?

 

Thanks

 

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi @v-paulp to do this you need to clone Knowledge Article content widget.

In Server side script look for below line which should give you knowledge base name

HarishKM_0-1715911202980.png

and in HTML add this to the condition which shows edit article button yellow color highlighted below. this should work.

 

HarishKM_1-1715911245283.png

 

Regards
Harish

View solution in original post

6 REPLIES 6

Harish KM
Kilo Patron
Kilo Patron

Hi @v-paulp to do this you need to clone Knowledge Article content widget.

In Server side script look for below line which should give you knowledge base name

HarishKM_0-1715911202980.png

and in HTML add this to the condition which shows edit article button yellow color highlighted below. this should work.

 

HarishKM_1-1715911245283.png

 

Regards
Harish

Hi @Harish KM 

Thanks it's working.

Can you please help me with the second requirement , we want add a another option named " Review update date" under action button drop down list same as flag and edit article option and when anyone click that option the review date of the kb article will automatically update to 12 month later.

 

I have  added below script in the widget,

HTML CODE
<li class="kb-menu-entry"><a ng-click="c.Review(data.article_sys_id)">{{data.messages.REVIEW}}</a></li>

Client script
c.Review = function(des){
alert(des);
c.data.reviewtime=des;
c.server.update().then(function(){
c.data.reviewtime="";
})
}//update the review date

Server Script 

if(input && input.reviewtime){
var grupdate = new GlideRecord('kb_knowledge');
if(grupdate.get(input.reviewtime)){
var actualreviewdate = grupdate.u_review_date;
var gdt = new GlideDateTime(actualreviewdate);
gdt.addMonths(12);
grupdate.u_review_date=gdt;
grupdate.update();
}
}

 

The button is showing but when I click the button it is not updating the review date the kb article.

 

Hi @v-paulp modified your client and server a bit, can try below

HTML CODE
<li class="kb-menu-entry"><a ng-click="c.Review(data.article_sys_id)">{{data.messages.REVIEW}}</a></li>

Client script
c.Review = function(des){
alert(des);
c.data.action = "getDate";

c.data.reviewtime=des;
alert("test Before " + c.data.reviewtime);

c.server.update().then(function(response){
alert("test After " + response.u_review_date);//check this alert

})
}//update the review date

Server Script


if (input){
if (input.action == "getDate"){
var grupdate = new GlideRecord('kb_knowledge');
if(grupdate.get(input.reviewtime)){
var actualreviewdate = grupdate.u_review_date;
var gdt = new GlideDateTime(actualreviewdate);
gdt.addMonths(12);
grupdate.u_review_date=gdt;
grupdate.update();
}
}
}

 

another way to do is refer below

https://www.servicenow.com/community/developer-forum/updating-a-record-in-a-service-portal-widget/m-...

Regards
Harish