Pass 3 arrays through Events using gs.eventQueue()

Kumar38
Kilo Sage

I have 3 arrays to pass to events . Is there a way to pass  more than 2 Parameters through gs.eventQueue()

1 ACCEPTED SOLUTION

Hi Shankar,

you can use array of json objects and pass that in single event parameter in event.parm2

use that in parsing in the email script

sample json should look like; sample email script

[
  {
    "fieldLabel": "Short Description",
    "previousValue": "Test",
    "currentValue": "Testing 123"
  },
  {
    "fieldLabel": "Assigned To",
    "previousValue": "Abel Tuter",
    "currentValue": "David Loo"
  }
]

parsing in email script

var str = '[{"fieldLabel":"Short Description","previousValue":"Test","currentValue":"Testing 123"},{"fieldLabel":"Assigned To","previousValue":"Abel Tuter","currentValue":"David Loo"}]';

var parser = JSON.parse(str);

for(var i=0;i<parser.length;i++){

template.print('Field ' + parser[i].fieldLabel + ' changed from ' + parser[i].previousValue + ' to ' + parser[i].currentValue);

}

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

5 REPLIES 5

Bhairavi Gandhi
ServiceNow Employee
ServiceNow Employee

Hi Shankar,

Please refer https://developer.servicenow.com/dev.do#!/learn/learning-plans/orlando/new_to_servicenow/app_store_l... to check what parameters can be passed to the event queue.

 

Regards,

BG

Jaspal Singh
Mega Patron
Mega Patron

Hi Shankar,

 

OOB gs.eventQueue() has option to pass only 2 parameters. Would you like to elaborate about your requirement so that an alternate way can be suggested.

I have a requirement to send notifications to a user , when any of the 13 fields are updated . So, created 3 arrays , 1 to capture field labels , 1 to capture previous values and 1 to capture current values

Thanks Shankar that helps understand the scenario.

I guess your event would be using a notification so why not you go for an option of mail script that is called in notification body (with format of label, previous, current value) & which is triggered when event is fired.