How to send a email using Workspace client script in Servicenow operation workspace through an event

Sree Harsha2
Tera Contributor

We have a UI action & we're expecting that once we click on that UI action , it has to send an email automatically based on the event in Service Operation Workspace view.
Attached is the Workspace client script in the UI action & the related script include which is called in that UI action , currently the email is not getting triggered based on the notification/event call.

Kindly check and advise if any changes required.

Thank you!

8 REPLIES 8

@Sree Harsha2 

in your notification you have marked Event parm1 contains recipient but you are not sending any recipient

update your line as this

	gs.eventQueue("incident.status.update", gr, gr.assigned_to.toString());

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hey @Sree Harsha2,

You have checked Event parm 1 contains recipient  but look at your Script Include:

gs.eventQueue('incident.status.update', gr);

You are NOT passing any value in parm1 or parm2. You only passed the event name and the record. The notification is looking for a recipient in Event parm 1 but it's empty.

Change your Script Include event line to:

gs.eventQueue('incident.status.update', gr, gr.assigned_to.toString());

 

 

Tanushree Maiti
Tera Patron

Hi @Sree Harsha2 

It is not working because gs.eventQueue() is a server-side function, while you are trying to call it from client-side code (Workspace Client Script).

 

Any code written inside the onclick function of a UI Action executes on the client side.

To make this work, remove the onclick function and place the code directly in the UI Action script so it runs on the server side.

 

 

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Tanushree Maiti
Tera Patron

Hi  @Sree Harsha2 

 

It is not working because gs.eventQueue() is a server-side function, while you are trying to call it from client-side code (Workspace Client Script).

 

Any code written inside the onclick function of a UI Action executes on the client side.

To make this work, remove the onclick function and place the code directly in the UI Action script so it runs on the server side.

 

Refer: 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti