Generating an array of requests for email notification

dscov22
Tera Contributor

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

1 REPLY 1

Karthiga S
Kilo Sage

Hi @dscov22 

 

  1. Create a new event in Event registry 
  2. Post this in BR, use gs.eventQueue to trigger the event
  3. 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!