Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..
400 views

Possible to submit multiple notifications from Send HTML Email rule?

Is it possible to submit multiple notifications from a Send HTML Email rule?  I'm on Service Manager 9.41.  What I need to do is loop though an array of groups and send a notification to members of each group in the array.

I currently have a for loop set up, but it only sends to the users variable from the last iteration of the for loop:

for (var i = 0; i < arrayLength; i++) {
   print("CI: "+assetStringArray[i]);
   users=lib.xcelUtilities.GetGroupApprovers(assetStringArray[i]);
   print ("Users: "+users);
}

 

 

 

 

 

 

 

0 Likes
4 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Possible to submit multiple notifications from Send HTML Email rule?

I guess you need two loops, one for looping the asset array and another array for users the lib returns. Something like this:

 

var tempUsers = new Array; var users = new Array;

for (var i = 0; i < arrayLength; i++) {
   print("CI: "+assetStringArray[i]);
   tempUsers=lib.xcelUtilities.GetGroupApprovers(assetStringArray[i]);

   for (var j=0; j<system.functions.lng(tempUsers);j++) {
      users.push(tempUsers[j];
   }

}
print ("Users: "+users);

 

 

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish
0 Likes
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Possible to submit multiple notifications from Send HTML Email rule?

Thank you very much for your reply.  This works - except that I'd like to send a notification for each iteration of the outer for loop - so each group receives a separate notification.  Is this possible?  I tried making users into a two dimensional array, and received a parsing error from the mailer process.

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Possible to submit multiple notifications from Send HTML Email rule?

OK, I understand what you're looking for but I believe HTML EMail rule doesn't support such a functionality.

Only way to do this (that I know) is to forget HTML rule and create a JS rule, use legacy RAD function and a notification record to send emails. I believe that's a bit so-so these days and could be deprecated later, but it works now.

You can send email by using a following function:

  • recipient = user name or assignment group (in notification record, set column "recipient(s)" accordingly)
  • notification = a notification "rule" in a table notification, note: check OOB notifications to get an idea how to use HTMLTemplates in notifications
  • file = RECORD
  • oldfile = RECORD (in this case)
function callRADMailFunction( recipient, notification, file, oldfile ) {
	
	var names = new SCDatum();
	names.setType(8);
	names = system.functions.insert(names, 0, 1, recipient);
	var retval;
	var rc = system.functions.rtecall("callrad", retval, "us.notify", ["name","record","names"], [notification, file, names, oldfile], false);
	
}

Disclaimer: I have not tested the code when called from the ruleset. I've fiercely tried to get rid of old legacy structures and use PD way of doing things, what I believe is a best practice in a long run.

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Possible to submit multiple notifications from Send HTML Email rule?

Thanks for your help with this.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.