What constitutes a Query for a query business rule to execute?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 04:31 PM
I have an After business rule on the rm_story table that works exactly as expected for Insert and Update events.
I wanted to have the rule run once on all records in the table after successful implementation so, (in dev) i added the 'Query' option as well. I assumed i could just open a list view of the table and that would fire the business rule but it did not. Second, i tried to query the table from a Background script:
var a = 0;
var st = '';
var strygrp = new GlideRecord('rm_story');
strygrp.query();
while(strygrp.next())
{
a = a + 1;
st = strygrp.state;
}
gs.print(a);
after executing this script, it returned the number of records in the table (the 'a' variable) but the business rule did not execute.
Any thoughts on why it did not fire the business rule? what constitutes a 'Query'?
to make sure the BR is not executing, i added a gs.log statement and verified the logged event when i updated a record then verified there was not a new log event after executing the script above - as a background script.
any help is appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2018 08:40 AM
i posted the business rule above.
basically i want the business rule to run one time against each record.
my next thought is to keep the business rule in place and update each record with a small value in an obscure field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 07:19 AM
Well i ended up going a different direction.
instead of using the Query event I kept the business rule as is and used the background script to add a work_note to each record. This triggered the update condition and the business rules ran for each story.
This was only acceptable because there are not a huge number of records because it also triggers all other update BR's.
Thank you for you replies! I think i have more research ahead of me to understand the Query event.