The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Stop addInfoMessage Displaying twice

aladpereira
Mega Expert

Hello,

I am using a BR script in Test Management module to update test case Execution status based on Child test status. But the addInfoMessage displays twice. How to stop it

Tried this script running in Before and After scripts couldn't fix it:

Running the script in--   test case[tm_test_case_instance] table

  var sysid = current.sys_id;

      var ctest = new GlideRecord("tm_test_instance");           // test table

      ctest.addEncodedQuery('execution_status!=passed^tm_test_case_instance='+sysid);

      ctest.query();

        if (ctest.getRowCount()==0)

              {

              gs.addInfoMessage("passed");

              }

addinfomessage error.jpg

How to fix this, anything wrong with the script?

Thanks,

Alad.

12 REPLIES 12

Jace Benson
Mega Sage

Im just guessing, but why do a rowcount when this should also work;


var tm_test_instance = new GlideRecord("tm_test_instance"); // test table


var query = 'execution_status!=passed^tm_test_case_instance=' + current.sys_id;


tm_test_instance.addEncodedQuery(query);


tm_test_instance.query();


if (!tm_test_instance.hasNext()) {//if there arent any records found, it is passed


      gs.addInfoMessage("passed");


}


my guess is for some reason, ctest.getRowCount() returns false which when compared with '==' to 0 returns true, and then it must get triggered again, perhaps theres an after business rule doing another update.


Thanks for the Reply, i have tried your script with deactivating all the after and before business rule associated to that table, but still i am getting it twice.


I have seen this behavior as well - it seems to be fairly inconsistent. Would be interested to see if there is any fix for this.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022