Notification on sc_task table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2015 12:08 AM
Hello,
I have a notification on sc_task table where I am trying to add a condition, when the request item is on specific stage, notification should trigger.
So far I have included the condition with the AND statements provided:
Request item.Stage contains 'Stage Name'
but notification doesn't seem to triggered.
I have also tried including it as an advanced condition, with following script:
var answer = false;
condition();
function condition(){
var gr = new GlideRecord('sc_req_item');
gr.addQuery("sys_id",current.request_item);
gr.query();
if(gr.next()){
if(gr.stage == 'Stage Name''){
answer = true;
}
}
return answer;
}
I have used a similar script on other notification and they work fine. The only difference is that working notifications are calling on approvals table and above calls on the tasks.
I am not great at scripting, and I get the sense the addQuery might be wrong. Please help.
Thank you so much in advance.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2015 04:24 AM
Looks like you have quotes mismatched
if(gr.stage == 'Stage Name''){
should be
if(gr.stage == 'Stage Name'){
Hope that helps
R

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2015 06:11 AM
I tried with the condition builder but don't know why it is not displaying the stage choices is it.
But you can do it using the advanced condition provided in the Notification. Use below code-
if(current.request_item.stage == 'value_of_stage_choice') //it should be values and not the name here
answer = true;
else
answer = false;
You don't need to declare the answer variable neither you need to return it.
Paste the above code as it is and just replace the 'value_of_stage_choice' with the actual stage value in the if condition.
Thanks,
Tanaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2015 09:05 AM
Hello Tanaji,
I tried the code, for some reason Stages are not being picked up in the notifications, not even through the script. Could it be something related to the workflow or how stages were created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2015 09:36 AM
Make sure you are picking the value of the stage than the label. For e.g. if you want to compare the stage 'Waiting for Approval' then the comparison should be with the value 'waiting_for_approval'.