Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to send multiple values to notification using gs.eventQueue()

dev115415
Tera Expert

Hello

I want to send multiple values like 8 to 10 values from my script include to email body of Notifications. I am using event triggering based approach. How to send this.

2 ACCEPTED SOLUTIONS

Weird
Mega Sage

What type of values?
One example would be to create a JSON object, send that and handle the values in email script.

For example:

obj = {};
obj.value1 = "value1";
obj.value2 = "value";
objString = JSON.stringify(obj);

gs.eventQueue('event_name, current, objString, "");

In your event you pass the objString and then in the email script you can parse it as:

var obj = JSON.parse(event.parm1);
//Then you can either loop it or access the values how you want.

for(var i in obj){
template.print(obj[i]);
}

//or
template.print(obj.value1);

View solution in original post

Community Alums
Not applicable

Hello, 

In notification -> What it will contain section, you can make use of mail script like this

Brunda_0-1685953505804.png

And you can create the email script to fetch the values from the object

Brunda_1-1685953617670.png

 

If my response resolves your issue please mark correct or helpful. 

Thank you

View solution in original post

7 REPLIES 7

<br>
For example

template.print("Hello,<br>How are you?");

 

Thanks @Weird  Can you tell me if we have Websockets in ServiceNow?

Yes, though I can't say I'm very familiar with the concept.
Websocket has been around for a while and it should be enabled by default if I remember correctly.