How to change the prefix of existing knowledge articles (KB)?

trout1974
Kilo Guru

How can I change the prefix on existing KBs within a knowledge base, and then of course new kbs created will have the new prefix?

I would presume there is someway to run a script or something along those lines.. I am not a developer, I have dabbled a little bit, I am a Knowledge Manager who likes to get the whole idea together before I present it. Any help you can provide is greatly appreciated. 

In the end.. the plan is to remove the existing default prefix "KB" and update it to another prefix, and update all the existing KBs within the knowledge base also, without breaking any of the existing permalinks. 

Thank you again, 

2 ACCEPTED SOLUTIONS

@trout1974 to update prefix of existing records, you can create a fix script then execute it.
Here is an example of fix script:

var existingKB = new GlideRecord('kb_knowledge');
existingKB.setLimit(1);
existingKB.query();
while(existingKB.next()){
existingKB.number = changePrefix("KB", "KNOW", existingKB.number);
existingKB.update();
}
function changePrefix(oldPrefix, newPrefix, number){
var x = number.split(oldPrefix);
return newPrefix+ x[1];
}

View solution in original post

@trout1974 unfortunately, the permalink is related to the number of the KB.
So the update of the number will break the existing permalink.

I don't have simple solution in mind to preserve the existing permalinks (related to the old prefix)


View solution in original post

6 REPLIES 6

Jean-Emmanuel
Tera Guru

Hello @trout1974 ,

You can change the prefix for new KBs by following this procedure:
1. Type sys_db_object.list in the Search bar on the menu then type Enter (to open the list of servicenow table)

2. Filter the list by typing "=Knowledge" in the search case under Label column then type enter
3. Open the record Knowledge & click on the Control tab
4. Update the prefix field with the new prefix
see image below for illustration
servicenow update prefix.png

 

Thank you so much for the instructions along with images. Would you happen to know how to convert the existing KB's to the new prefix?

In doing so, do you know if it would "break" the existing permalinks or can it be "related/attached/replaced" in some manner that you know of?

@trout1974 unfortunately, the permalink is related to the number of the KB.
So the update of the number will break the existing permalink.

I don't have simple solution in mind to preserve the existing permalinks (related to the old prefix)


@trout1974 to update prefix of existing records, you can create a fix script then execute it.
Here is an example of fix script:

var existingKB = new GlideRecord('kb_knowledge');
existingKB.setLimit(1);
existingKB.query();
while(existingKB.next()){
existingKB.number = changePrefix("KB", "KNOW", existingKB.number);
existingKB.update();
}
function changePrefix(oldPrefix, newPrefix, number){
var x = number.split(oldPrefix);
return newPrefix+ x[1];
}