Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Notification to(script) in workflow

rody-bjerke
Giga Guru

Hi,

I'm trying to script who should get an email notification from the system, through workflow.

I've created a Notification activity like below:

find_real_file.png

Then i want to send an email to requested_for (reference to sys_user), requested_for is a variable so i've tried adding:

current.variables.requested_for

At the same time i want to send the same mail to the requested_for's manager. The manager is set in a seperate field, so i've tried using:

current.variables.manager.

Any idea on how to use this TO (Script) to make it work?

Best regards,

1 ACCEPTED SOLUTION

rody-bjerke
Giga Guru

Solution: (where you can add answer.push for both user and manager):



answer = [];


answer.push(current.variables.manager.sys_id);


View solution in original post

5 REPLIES 5

Gowrisankar Sat
Tera Guru
To (script)If Advanced is selected, this script is called and should set the variable answer to a comma-separated list of user or group sys_ids that you want to add as recipients of the email.


It should be something like:



answer=current.variables.VAR_NAME;  


gtalreja
ServiceNow Employee
ServiceNow Employee

Hello Rody,



You can achieve this without scripting from the workflow notification activity using "dot-walking" method.



you can click on "select field " and use dot walking as follows:



Screen Shot 2017-11-29 at 5.56.55 PM.png



1) Request--> Requested For


2) Request--> Requested For-->Manager


Screen Shot 2017-11-29 at 5.57.19 PM.png



Regards,


Gaurav Talreja


Hi Guarav,


using the 'select fields' dot walking method doesn't seem to work for me. if i use a field from that the email doesn't fire at all. However if i enter a specific email address or select a specific user it does fire the email. Any idea why that could be? I'm working off the Catalog Task (sc_task) table. Does that make a difference?





thanks,


denise


rody-bjerke
Giga Guru

Solution: (where you can add answer.push for both user and manager):



answer = [];


answer.push(current.variables.manager.sys_id);