- 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 08:23 AM
I am sorry, I am here again. The script is working fine. I have also developed an email notification to send to the users once the request has been opened. Now I have to put an additional condition to send the email.
The current process : When we reject/approve the task, an email is sent. And when we close the request, an other email is sent to notify the processind of the applicationl.
What I want : I don't want to send the second email if there is only one task/ritm inside the request and if the task has been rejected (because users receive two emails). But if the request has at least two tasks/ritms, we want to send both emails (no matters if they all were approved or rejected).
To sum up :
more than 2 tasks/ritms : 1 approved and 1 rejected >>> two emails (rejection - request completed)
only 1 task/ritm : approved >> two emails
only 1 task/ritm : Rejected >> 1 email (only rejection)
I tried to add the script above in email notification, advanced condition of the second Email (request completed).
I don't know if it is the easy way and if it is possible to do like that.
Furthermore, the idea is, if the result of script above return more than 1, not send the email.
I don't know if this kind of condition will be considered. I mean if it returns false, i am not sure that the email will not be sent.
This is the screenshot. Any idea Please ?
Kind regards
ZA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 11:23 PM
Zic,
I suggest you to try with events for generating email notification so that your requirement can be fulfilled.
Regards,
VimalPriya S

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2015 04:03 AM
Hi Akb,
Sorry for the delay. Glad to help you
From my understanding, I can say that you always want the approval/rejection notification to be triggered. You only have to control the notification on closure of RITM based on the no of RITMs and 'Approval' field on RITM form.
So go to you notification triggered on the closure of the RITM and add the conditions and script into it as shown in below.
In above script:
If there is only one RITM with the REQ, I have checked the 'Approval' field on the RITM. If you want the 'Approval' field on the REQ to be checked here then replace 'current.approval' used in the script with 'current.request.approval'.
Also in the condition builder I have checked for all the RITM state choices starting with Closed.
You can change the condition as required. Don't check approval field in the condition builder as we are using it in the script.
This should work for you
Thanks,
Tanaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2015 07:48 AM
Hi Patil,
Thank you very much for your reply> I am really sorry for my late reply, I took my friday off.
I have just one question please>>> How the system will interprate the meaning of the boolean "answer" ?
I mean, how does he know that t want to send the email if the boolean is true, and I want no sent when if it is false ?
I look forward for your reply.
Thank you very much again
Kind Regards,
ZA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2015 07:59 AM
What does answer = true means ? Does it mean that the system will send the email or it means that the system won't send it ?