How to pass more than 2 parameters in a single event?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2023 04:45 AM
Hi, I am firing a event from inbound action with delay of 5 min using gs.eventQueueScheduled. This event once processed, will trigger one "Script Action" whose role is to create an incident. In the event I want to pass following parameters.
1) subject
2) body_text
3) Priority of the incident (number/string e.g. 3)
4) CI (a string e.g, Azure DevOps)
5) Host (a string which will get mapped to a custom incident field)
Now, I am only able to pass the subject and body_text. I want to pass the rest 3 to.
Please guide me on the solution.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2023 05:10 AM
Event can accept only two parameters. However you can create JSON object and pass them. Refer sample to convert to JSON and pass data:
var param = {};
param.subject = "value of subject";
param.body_text = "value of body text";
param.priority = "value of Priority";
param.ci = "Value of CI";
param.host = "Value of Host";
gs.eventQueue('event',current,JSON.stringify(param));
Refer the below Script for parsing the data at the other side:
var param = JSON.parse(event.parm1.toString());
template.print(param.subject);
template.print(param.body_text);
template.print(param.priority);
template.print(param.ci);
template.print(param.host);
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2023 11:59 PM
@nirwan_ritik , to pass the rest of the parameters to the Script Action, you can use the payload parameter of the gs.eventQueueScheduled() function.
The payload parameter is a JSON object that can be used to pass data to the Script Action.
EXAMPLE:
To use the payload parameter to pass the rest of the parameters to the Script Action:
var payload = {
priority: 3,
ci: 'Azure DevOps',
host: 'My Host'
};
gs.eventQueueScheduled('my_event', current, payload, 5);
In the Script Action, you can access the payload data using the payload variable.
EXAMPLE:
To access the payload data in the Script Action:
var priority = payload.priority;
var ci = payload.ci;
var host = payload.host;
// Create the incident.
var incident = new GlideRecord('incident');
incident.setValue('subject', current.subject);
incident.setValue('description', current.body_text);
incident.setValue('priority', priority);
incident.setValue('u_ci', ci);
incident.setValue('u_host', host);
incident.insert();
This code will create an incident with the specified subject, body text, priority, CI, and host.
Kindly, please mark my solution as Helpful/Correct, if applicable. If I could help you with your Query then, please hit the Thumb Icon and mark as Correct!!!
Thanks & Regards,
Revanth. K
Product Test Automation Engineer