Generating an array of requests for email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2023 02:15 PM
Hi again,
I have a requirement to fulfill that I'm unsure where to start with. Here is the requirement:
"Whenever a new record is inserted into the queries table send a notification to the requester. The notification should include a table of all open requests opened for that same requester. The table will have a row for every record with a few fields from each record."
I have a BR that tallies current requests for that requester, this is that BR:
(function executeRule(current, previous /*null when async*/) {
//count variable for amount of records a requester has opened
var count = 0;
//new record in the queries table
var grD = new GlideRecord('u_chromatech_customer_queries');
//query requests from requester
grD.addQuery('u_requester',current.u_requester);
grD.addActiveQuery();
grD.query();
//ierate and count through all rows found
while(grD.next())
{
count = grD.getRowCount();
}
//if 7 or more records exist
if (count >= 7 )
{
//error message and do not return
gs.addErrorMessage("Requester has 7 or more active requests. Please close an active request before opening another");
return false;
}
})(current, previous);
As for generating the table and including this in the notification, I am lost.
Any help and guidance would be appreciated, thanks for your time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2023 11:52 PM
Hi @dscov22
- Create a new event in Event registry
- Post this in BR, use gs.eventQueue to trigger the event
- Then, create a notification in the same table with the Created event as a trigger.
Syntax of eventqueue:
gs.eventQueue('event.name', GlideRecord, parm1, parm2);
Please mark it Correct and Hit Like if you find this helpful!