How to update the latest KB article display number in customized reference field

thaduri sai
Tera Contributor

Hi Team,

 

We have created a reference field (BIA Knowledge Article) in business application cmdb form.It will shows the KB article display number in the field.

thadurisai_0-1694936094773.png

 

So, If KB article expire after 1 year - Then users are updating the KB article through portal.

But Here Its not taking the new updated version number. Its still showing the old version number

thadurisai_1-1694936123562.png

 

Its showing the updated display number in the search box - But its not taking the new value in the field. Still we are updating this process manually - Kindly please assist.

thadurisai_2-1694936146361.png

 

We have return After BR - But its not working as expected.

thadurisai_3-1694936252249.png

 

thadurisai_4-1694936268767.png

 

Thanks,

Sai

1 ACCEPTED SOLUTION

Hi @babbi / @thaduri sai 

Try the following code and check the system log, if you didn't find any of the log statement, it means the BR didn't ran, if it is running observer which log statement is not logged.

 

(function executeRule(current, previous){
   var BIA = new GlideRecord("cmdb_ci_business_app");
   BIA.addQuery('sys_id', current.cmdb_ci);
   BIA.query();
   gs.info('Before BIA IF Condition');
   if(BIA.next()){
      gs.info('Found BIA');
      BIA.setValue('u_bia_knowledge_article', current.getUniqueValue());
      vat update_res = BIA.update();
      if(update_res){
         gs.info('Updated BIA KB Successfully');
      } else{
         gs.info('Updated BIA KB Failed');
      }
   }
})

 

Thanks,
Anvesh

View solution in original post

8 REPLIES 8

AnveshKumar M
Tera Sage
Tera Sage

Hi @thaduri sai ,

 

In your BR script the if condition is written as If (Capital I) instead of if in line number 11. And I feel like the entire line number 11 is not required. Please comment that line and save the BR then try updating the article and check whether the reference updated successfully or not.

 

Please mark my answer helpful/accept my solution as answer if it helped you to fix this issue. ✔️👍

 

Thanks,
Anvesh

Hi @AnveshKumar M ,

 

Could you please help on this - still its not running.

babbi_0-1695037133681.png

 

Hi @babbi / @thaduri sai 

Try the following code and check the system log, if you didn't find any of the log statement, it means the BR didn't ran, if it is running observer which log statement is not logged.

 

(function executeRule(current, previous){
   var BIA = new GlideRecord("cmdb_ci_business_app");
   BIA.addQuery('sys_id', current.cmdb_ci);
   BIA.query();
   gs.info('Before BIA IF Condition');
   if(BIA.next()){
      gs.info('Found BIA');
      BIA.setValue('u_bia_knowledge_article', current.getUniqueValue());
      vat update_res = BIA.update();
      if(update_res){
         gs.info('Updated BIA KB Successfully');
      } else{
         gs.info('Updated BIA KB Failed');
      }
   }
})

 

Thanks,
Anvesh

Thanks @AnveshKumar M  - Its working now.