- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 12:47 PM
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,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 01:34 PM
@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];
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 01:49 PM
@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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 01:36 PM
In the previous script, note that:
- I assume that the new prefix is "KNOW"
- The second line with setLimit syntax limit execution to a single record. (deleted this line will update the prefix of all existing KB)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2024 01:44 PM
Thank you, I don't need it perfect, I just needed a bump in the right direction, I will pass this info along with my pitch and see if they will accept the change. Thank you again.