Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Events: firing an event from a related table and passing multiple sys_ids in 1 parm to a notification.

josh_tessaro
Giga Expert

I am trying to fire an event from a workflow that is running for Incident SLAs. This workflow is running on the task_sla table.

I need to be able to fire an event for the task_sla.task (always incident in this case) that will trigger a notification on the incident table. parm1 should include the list of recipients.

I am having two problems:

1. how do I fire an event on a related table?

Instead of: gs.eventQueue(<eventName>,current,<parm1>,<parm2>);

I need to be able to send: gs.eventQueue(<eventname>,current.task,<parm1>,<parm2>);

When I do this now and look at the EventLog it is not registering the correct table (its showing the sys_id of the current.task record) and is not registering the value of either parm.

2. How can I pass multiple recipients to a notification from an event? I have tried a comma separated list of sys_ids with no luck but that could be because of the issue in item 1 above where the parameters are not being registered presumably because of the bad table identifier.

Thanks!

5 REPLIES 5

Zach Biewend1
Giga Expert

You are correct about number 2. A comma delimited list of sys_ids from the sys_user table, or sys_user_group table, will populate properly, as long as your notification that responds to that event has the box checked for 'recipients in parm 1' (or whatever it says).



For 1, I believe current.task is only a string with the sys_id. This parameter in gs.eventQueue() needs a record object. You will have to run a simple query to retrieve that object.



var recipList = '';


// do something here to put sys_ids in recipList...



var inc = new GlideRecord('incident');


inc.get(current.task); // gets the incident record object from sys_id



gs.eventQueue('eventName', inc, recipList, 'parm2value...');



Hope this helps!


Zachary,



I am close to doing what I need but I am having an issue where if the event parm1 contains multiple sys_ids the notification is not generating. Do you know what the limitations are surrounding what you can pass to a notification via an event parameter?


So this is close but the event is getting marked as an error when being processed. Here is what we have:



var gr = new GlideRecord('incident');


gr.get(current.task);



gs.eventQueue('<Eventname>', gr,current.task.assignment_group.sys_id +'', gr.number +': notify assignment_group');



The event shows up in the Event Log and parm1 is correct however parm2 reads: undefined: notify assignment_group



I added the following code piece:


gs.log('TEST EVENT\nsys_id to query: '+current.task+'\nsys_id found: '+gr.sys_id+'\ngr.number: '+gr.number);



Which yields this:



When I test similar functionality in a fix script, I am able to print gr.number after the get(). Any ideas?


That's a bit strange. I'm not sure why gr.sys_id works, but gr.number does not. You might try gr.number.toString(), but I don't think that's the issue. You also might test gr.short_description to see if that works. I'd also try not concatenating it with a string, just to see if your results are different. I'd expect passing just ': notify...' to work, but try passing just gr.number, or gr.number.toString(), or gr.short_description.