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

Hello Arnie,


Yes, I have included the value and not the name. Unfortunately it is still not being picked up in notification script.


arnie
Mega Contributor

Can you please share a screenshot of the workflow activity?


Hello Arnie,


here it is, I am using 'test' as my stage, every stage has a different value at each task


workflow.pngstage.png


The stages are workflow created. So you cant access those stages in the condition builder. But you should be able to use those in the script.


And why don't you trigger the notification using the workflow notification activity in your workflow? It would be easier.


Hello Tanaji,


I tried triggering notification through script:



if(current.request_item.stage == 'verify')


                answer = true;  


else  


                answer = false;  



stage on workflow is not being identified by the task. I tried also including the notification using the workflow activity   and it did not triggered either. I am a bit confused as to why would it not trigger even when including it through the workflow.


Any ideas?