Skip to Content
0

Redwood BPA: Process Alert Source Parameter Match on Out Parameter

Apr 30 at 08:03 PM

51

avatar image

Hi,

Is it possible to have a Process Alert Source match on an Out parameter from the job? I have a job that sets an output parameter as a post action (with Java), and I would like a Process Alert Source to trigger if that output parameter is certain values, but when I try this, it seems that it doesn't see the value of the output parameter. It only seems to trigger on the input value of parameters.

Is this expected? Is there a way to force the setting of the output parameter from the Post Action that can actually be seen by the Alert Source?

Thanks!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Abhishek Singh May 02 at 03:28 PM
0

If I understood clearly, then you are able to raise an alert but it's output parameters should be certain values to do something.

If it does raising an alert, then you can create an "Email Alert Gateway Action Pre Send" (followed by Alert Escalations) and overwrite or check the values in Action > Pre Send through the Alert gateway. Even you can delete the alert object which doesn't match you're required before sending the actual alert.

Regards,

Abhishek

Share
10 |10000 characters needed characters left characters exceeded
Dallas Beahm May 03 at 03:24 PM
0

Thanks for the response!

What I'm trying to accomplish, is have an alert only send when the associated job has a spool generated. If no spool is generated, I want the alert to not be sent.

What I tried, was creating a new Out type parameter for the job itself, called "SEND_EMAIL", which I can set to true or false in the Post Running action on the job. I then tried matching on the parameter SEND_EMAIL = "true", but it doesn't seem to consider the values of "Out" parameters, and the email isn't sent when the parameter is "true".

So what you are suggesting, is to delete the alert itself from the Pre-Send action in the gateway?

It seems like the sequence would be:

if (jcsEmailAlertGatewayPreSendActionContext.getAlert().getAlertSource().getSourceObject() instanceof Job)

and if it's a "Job", cast it to Job:

Job alertJob = jcsEmailAlertGatewayPreSendActionContext.getAlert().getAlertSource().getSourceObject();

then get the SEND_EMAIL parameter:

JobParameter jp = alertJob.getJobParameterByName("SEND_EMAIL");

and if it's not null, check to see if the value is true, and if not, it seems like

jcsEmailAlertGatewayPreSendActionContext.setSend(false) might do the trick?


I'm not sure about that method name, my API documentation, which is a bit old, has "sendSend(boolean send)", but it might just be a typo.

Or is it actually necessary to call:

jcsEmailAlertGatewayPreSendActionContext.getAlert().deleteObject()?

I'll try a few of these things to see if I can get it working. Thanks again!

Share
10 |10000 characters needed characters left characters exceeded
Dallas Beahm May 03 at 04:30 PM
0

Ok, not to leave anyone without a solution...

The actual method is "setSend(boolean send)"... "sendSend(boolean send)" does not exist.

Here's a working solution. This checks for any attachment named *spool* and if one is present, it sends the email.

Edited to add: You could also just do everything in the gateway, but I wanted it to be up to the job creator whether the job would suppress emails if no spool. This way, the code can be added to all gateways, and then just jobs that want to suppress emails can add that chunk of code.

Here's the code for the Job (Requires the process definition to have an Out parameter SEND_EMAIL):

{
  JobParameter jp = jcsJob.getJobParameterByName("SEND_EMAIL");
  if (jp==null) throw new RuntimeException("Couldn't get job parameter specified");

  Iterator it = jcsJob.getJobFiles();

  while(it.hasNext()) {
  
    JobFile jf = (JobFile)it.next();    
    jcsOut.println("Jobfile: " + jf.getName());
    
    if (jf.getName().contains("spool")) {
      jcsOut.println("Spool found.  Setting SEND_EMAIL to true."); 
      jp.setOutValueString("true");
      return;
    }
    
  }

  jcsOut.println("No spool found.");    
  jp.setOutValueString("false");

}

And here's the code for the Gateway:

{
if (! (jcsEmailAlertGatewayPreSendActionContext.getAlert().getSourceObject() instanceof Job) ) return;

  JobParameter jp = ((Job)jcsEmailAlertGatewayPreSendActionContext.getAlert().getSourceObject()).getJobParameterByName("SEND_EMAIL");
  
  if (jp == null) return;
  
  String sendEmail = jp.getOutValueString();
  
  if (sendEmail == null) return;
  
  if (sendEmail.equals("false")) {
    jcsEmailAlertGatewayPreSendActionContext.setSend(false);
    jcsEmailAlertGatewayPreSendActionContext.getAlert().getOperatorMessage().deleteObject();
    jcsEmailAlertGatewayPreSendActionContext.getAlert().deleteObject();
  }
}

Share
10 |10000 characters needed characters left characters exceeded