- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2015 04:56 AM
Hello There,
I started to work on servicenow recently and I am stuck. I really need your help. I have one question about the topic above.
-> I want to count the number of tasks for each request when the user click in the request row to open the request.
Let me explain : Le'ts say for example that the request number REQ001 has got 3 tasks (RITM0021, RITM002, RITM003). When the user click on REQ001, I want to collect that there is 3 tasks assigned to this request number.
This is the script I have written into UI ACTIONS, but It's not working :
var reqItems = new GlideAggregate('sc_req_item');
reqItems.addQuery('current.number');
reqItems.addAggregate('COUNT');
reqItems.query();
if (reqItems.next()) {
alert('task count: ' + reqItems.rows.length);
}
Thank you so much for your help
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 05:02 AM
Zic,
Its working fine in my instance.
Try doing in your instance.
Mark the answers helpful and correct .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 05:10 AM
Please check with below script-
var reqItems = new GlideRecord('sc_req_item');
reqItems.addQuery('request',current.sys_id);
reqItems.query();
if (reqItems.hasNext()) {
gs.addInfoMessage('task count: ' + reqItems.getRowCount());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 04:40 AM
Hi Zic,
I hope the problem occured in the When to run part of the business rule,
You have to select display in when field instead you selected before , as per suggestion provided by Tanaji .
Regards,
VimalPriya S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 05:02 AM
Zic,
Its working fine in my instance.
Try doing in your instance.
Mark the answers helpful and correct .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 05:37 AM
VimalPriya Syou were right. I changed in "display" the When to run and now I have what I wanted.
Thank you very much to all of you for helping me, specially @Tanaji Patil for your scripting.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2015 08:32 AM
I have the script working just like @Tanaji Patil said it wold! Is it possible to have the options go up the chain instead? I can't get my business rule to work on the Catalog Task [sc_task] table to count up to the # of RITM's? What update should I make to get that work?