- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 02:25 AM
Hi All,
I'm trying to get the count of the number of features associated with a release. I have written an after business rule on Insert, on the rm_feature table with the below code:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("rm_release");
gr.addQuery("sys_id", current.parent);
gr.query();
gs.log("Features = "+ gr.getRowCount());
while(gr.next()) {
gs.log("INSIDE WHILE Features = "+ gr.getRowCount());
}
})(current, previous);
Both the logs are giving gr.getRowCount() result as 1...even if there are multiple features already associated with the release.
Please assist.
Thanks,
Sarah
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 03:35 AM
Hi Sarah,
You are right.Your business rule should be in "rm_feature" table. Just change the script as below.
Change the script to:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("rm_feature");
gr.addQuery("parent", current.parent);
gr.query();
gs.log("Features = "+ gr.getRowCount());
while(gr.next()) {
gs.log("INSIDE WHILE Features = "+ gr.getRowCount());
}
})(current, previous);
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 02:51 AM
1.Write business rule in the "rm_release" table.
2. Script:
var gr = new GlideRecord("rm_feature ");
gr.addQuery("parent", current.sys_id);
gr.query();
gs.log("Features = "+ gr.getRowCount());
while(gr.next()) {
gs.log("INSIDE WHILE Features = "+ gr.getRowCount());
}
Check log.You can find the count of the number of features associated with a release.
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 03:11 AM
Hi Mihir,
I had thought of doing this, but couldn't decide on what condition should the BR fire.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 03:35 AM
Hi Sarah,
You are right.Your business rule should be in "rm_feature" table. Just change the script as below.
Change the script to:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("rm_feature");
gr.addQuery("parent", current.parent);
gr.query();
gs.log("Features = "+ gr.getRowCount());
while(gr.next()) {
gs.log("INSIDE WHILE Features = "+ gr.getRowCount());
}
})(current, previous);
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 03:43 AM
Thanks Mihir,
This approach is giving the correct result!
I'm still confused though, as to why the glideRecord into the release form was not able to give the result.
Thanks, at least you found a workaround
Regards,
Sarah