The CreatorCon Call for Content is officially open! Get started here.

Notification on sc_task table

prl1120
Kilo Explorer

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.

13 REPLIES 13

Hi,



if(current.request_item.stage == 'value of your stage choice used in workflow')


                answer = true;


else


                answer = false;



Writing this script in the advanced script field of your notification on sc_task should work.


I checked it and its working fine.


Please check your stage value used.



If you need reference please check 'Test Notification' notification on https://demo011.service-now.com/login.do


user - admin


password - admin



Thanks,


Tanaji


Also you can personalize/configure list layout to add 'stage' and use excel export of 'sc_req_item' table to see the value of the stages.


And also make sure you check 'send to event creator' in the notification.


Thanks Tanaji,


I will check on this and report if successful.