how to use para2 in email script and fetch data

Priya75
Tera Contributor

Hi All,

I have a scheduled job from where i am triggering an event and sending parm2,

i want to use this parameter in my email script to glide data from incident table.

 gs.eventQueue("eventname","current", parm1, parm2);

now i want to use parm2 which contains sys id of incidents, in my email script to glide the incidents and get their category, state and configuration item and display it in tabular format.

 

Incident Configuration Item CategoryState
inc1234567xyzxyzxyz
inc4546567abcabcabc

 

3 REPLIES 3

Peter Bodelier
Giga Sage

Hi @Priya75,

 

You can use event.parm1 and event.parm2 to read these from the event.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

asifnoor
Kilo Patron

Hello Priya,

 

Firstly,pass allyoru incidents to array and thenpass the array in param2 of the event.

 

Then in your email script,you can access the data as event.parm2. Here is the sample code.

var sysIds = event.parm2.toString().split(","); //split the incident sys_ids
template.print("<table><th>Incident</th>Configuration Item</th><th>Category</th><th>state</th>");
for(i=0;i<sysIds.length;i++) {
template.print("<tr>");
  var grInc = new GlideRecord("incident");
  if(grInc.get(sysIds[0])) {
    //form your table rows here. 
    template.print("<td>"+grInc.number+"</td>");
    template.print("<td>"+grInc.cmdb_ci+"</td>");
    template.print("<td>"+grInc.category+"</td>");
    template.print("<td>"+grInc.state+"</td>");
  }
template.print("/<tr>");
}
template.print("<table>");

  

Mark the comment as a correct answer and also helpful if this has helped to solve the problem.