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

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