Meta description disappearing on KB Article after saving/updating

Krissy
Giga Guru

Hi,

 

When trying to save or update the meta description on my kb article, the description disappears.  Any idea on how this can be resolved?

find_real_file.png

13 REPLIES 13

Did you try the approach which I have suggested above?

I ahve tested this in my PDI. There is a Business Rule which exists OOB named "Populate Meta Description" which is an After Insert and Update BR which clears out the Meta Description when you Insert or Update a KB article.

BR Link:

https://instance.service-now.com/nav_to.do?uri=sys_script.do?sys_id=7ec7780523b30300cc4bcb0a56bf65c8

Replace "instance' with your instance name.

find_real_file.png

Disable/Modify this BR as needed and you will be good here.

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

OOB BR calls a Script Include named "KBViewModel" which contains a reference to another Script Include which is an Read Only protected SI where this method is validated "getArticleContentForMetaDescription" . Unfortunately the method contains some balck box code which is not exposed to us, at least I was not able to find it in the system.

So you can put a Log in your BR to debug this further that like from where this is fetching the value from or modify it accordingly.

But it's the OOB BR which is responsible for this behavior.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

yes, i am still looking into your suggestions and trying to see what can be changed for it to work

Hi,

Please use the updated code and it's working for me:

Update the same BR which I have highlighted above and use the code below. What's happening in the BR is by default the value of content is coming as Null which is handled but else logic is not handled. SO have updated the code and seems to be working correctly.

Please try the same and let me know if any issue.

(function executeRule(current, previous /*null when async*/ ) {

    var desc = "";
    var kbMod = new global.KBViewModel();
    var content = kbMod.getArticleContentForMetaDescription(current);
   
    if (!gs.nil(content)) {
        content = new GlideSPScriptable().stripHTML(content) + "";
       
        if (!gs.nil(content)) {
            var seoMetaDescLength = parseInt(gs.getProperty('glide.knowman.seo.pages.meta_description.length', 100));
            desc = content.substring(0, seoMetaDescLength);
           
            desc = desc + content.substring(seoMetaDescLength).split(" ")[0];
          
        } 
    }
    var article = new GlideRecord(current.sys_class_name);
    if (article.get(current.sys_id)) {
        article.setWorkflow(false); // no need to execute business rules on kb_knowledge
        article.setSystem(true);
        article.meta_description = current.desc;
        article.update();
    }

})(current, previous);

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi,

 

So i updated the script for the meta description BR. When i made a change on the meta description on the KB article, its not showing my custom description, its just showing the first sentence of the KB Article.