Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2022 01:15 AM
In that case the code should be something like:
var agg = new GlideAggregate("sc_req_item");
// Select Requested Items of the current Request
agg.addQuery("request", current.getUniqueValue());
// Select only those Requested Items that were created from Catalog Items that have a model associated with it
// It may be necessary to further qualify the selection here, but specifying model category (so that only software models are included)?
agg.addNotNullQuery("cat_item.model")
agg.addAggregate("COUNT");
agg.query();
if (agg.next()) {
var counter = agg.getAggregate("COUNT");
current.correlation_id = counter;
}
Also because the Business Rule runs on the same table as the one modified, this must be a Before Business Rule, not an After Business Rule.
'Cause we know the rules:
- No updating current in Business Rules; that means not only calling current.update(), but also loading the current record and updating it.
- If the current record is modified, it has to be a Before Business Rule
- If a different record is modified, it has to be an After Business Rule, unless what is modified is not loaded into the form in which case it can also be an Async Business Rule to allow faster form load times.