Stop addInfoMessage Displaying twice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2016 09:04 AM
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");
}
How to fix this, anything wrong with the script?
Thanks,
Alad.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2016 01:10 PM
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");
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2016 01:12 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2016 05:41 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2016 06:08 PM
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