BR 'Notify about article's checkout' is getting skipped when a new kb article created by a script

learn nv
Tera Contributor

Hi All,

I am creating a KB article through a script in an UI Action, Article is getting created but getting the following error message on the form.

"Conditon 'Condition: !(new KBCommon().isExternalArticle(current.article.getRefRecord())); Filter Condition: base_versionISNOTEMPTY^EQ' in business rule 'Notify about article's checkout' on kb_knowledge: KB0010440 evaluated to null; skipping business rule".

 

I am not seeing this error if we create an article manually.

 

Could you please suggest how to suppress this error? and I am not able to understand the code 'current.article.getRefRecord()', as I don't see any article field on the kb_knowledge table?

 

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

This is curious - maybe 'article' was a field that once existed and has since been renamed or deprecated, and ServiceNow never updated the condition?  In any event, if your UI Action is creating a new article, this BR should not be triggering as it should have the When to run Filter Condition of 'Base Version is not empty'.  This BR is meant to trigger when a published article is checked out (via the Checkout UI Action which is visible on published articles).  The Condition is still invalid, but it's just ignored in this case and no error message is displayed or appears in the logs, which is likely why it hasn't been updated/removed.

 

Is your UI Action creating an article by checking out a published one?  You can edit the BR to remove the Condition since it is not executing anyway.

Hi Brad,

Thank you for your reply. As per my understanding I am not checking out any published article. I am trying to create a new article and publish it. Below is the reference code I am using to do it.

 

https://www.servicenow.com/community/itsm-articles/automating-knowledge-base-article-creation-and-ve...

On first glance, I'm not seeing why KnowledgeUIAction.publish() inside this script creates multiple versions and populates the base_version on the resulting published article, when manually publishing a draft article by clicking the Publish UI Action button (which calls the same method in the same script include) does not.  I did not create an article populating all of the fields that the script does, so maybe one of those is triggering the versioning, or if you're creating the same article in multiple categories, which doesn't sound like a good approach from a versioning/maintenance perspective.

 

If the script is otherwise working for you to create a published article that ends up looking like it should, then I'd still say to remove the erroneous BR Condition to stop the error message from appearing.

Richard Mansfie
Tera Expert

I had a very similar issue this week. I was creating a UI action to save and publish a new article.

I ended up with the following which worked for me, might be useful for you.

 

action.setRedirectURL(current);
answer = current.insert();
gs.include('ActionUtils');
var au = new ActionUtils();
au.postInsert(current);
current.update();
new global.KnowledgeUIAction().publish(current);
g_form.clearMessages();