cancel
Showing results for 
Search instead for 
Did you mean: 

Redwood BPA: Process Alert Source Parameter Match on Out Parameter

Dallas1
Explorer
0 Kudos
494

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!

View Entire Topic
Dallas1
Explorer
0 Kudos

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