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);
}

 

 

 

 

 

 

 

  • 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);

     

     

  • 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.

  • 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.