cancel
Showing results for 
Search instead for 
Did you mean: 

Parameter Values in Email for Process Alert Source

Dallas1
Explorer
0 Kudos
335

Hi,

I am in the process of setting up a dynamic escalation path for a Process Alert Source. I want the escalation path to be constructed from a constant plus a parameter value from the job that triggered the alert source.

For the escalation expression, I have the following, which is working correctly, as it routes the email to different escalations/gateways depending on the VARIANT_SUFFIX from the job triggering the alert.

='ALERT_EMAIL_PM_WEEKLY_DATA_REPORTS_' + parameters.PLANT_NAME

I also have the same in the operator message expression (For the subject of the email), and this is working correctly.

=parameters.PLANT_NAME + ' BOMs Created Previous Week'

However, the problem I'm facing is when trying to display these parameters in the body of the email.

If I use: ${parameters.PLANT_NAME} in the body of the email, I literally get ${parameters.PLANT_NAME}, instead of the contents of the PLANT_NAME parameter.
If I use [?=parameters.PLANT_NAME?] in the body, I get an error: Plant Name: ERROR:20180917114808CST/19dbb82

Other standard parameters, such as ${jobDefinition} and ${jobID}, and even code such as [?=Variable.getString('THIS.SYSTEM.NAME')?] are working correctly, just the parameters are not translating properly.

Can anyone help with getting the parameters to display in the email?

Accepted Solutions (0)

Answers (1)

Answers (1)

gmblom
Active Contributor
0 Kudos

Which version are you running.

Regards Gerben

Dallas1
Explorer
0 Kudos

Hi Gerben,

We are running 9.1.0.6.

Thanks,

Dallas

Dallas1
Explorer
0 Kudos

Hi Gerben, just wondering if you have any further thoughts around this issue?

Thanks!

Dallas

Dallas1
Explorer
0 Kudos

Hi Gerben,

I gave that a shot, with no luck...

To simplify it, I added a new method "public static String getJobParameterTest(String testString)" in com.redwood.scheduler.custom.EmailHandling, which just returns testString.

I created an REL Entry Point with name "GetJobParematerTest", FQ Class Name of "com.redwood.scheduler.custom.EmailHandling", and Method Signature of "getJobParameterTest(String)".

Within the Process Alert Source email, I have the following:

..

[?=Custom.GetJobParamaterTest()?]

..

Unfortunately, when this triggers, the email still contains ERROR:20190605101525CST/251e6024.

I've tried also using custom.GetJobParameterTest('Test Content'), com.redwood.scheduler.custom.GetJobParameterTest('Test Content'), and com.redwood.scheduler.custom.EmailHandling.GetJobParameterTest('Test Content'), but all of these still return an error. Am I not referencing the REL method properly?

Thanks,

Dallas

gmblom
Active Contributor
0 Kudos

Hi Dallas,

You have almost tied the knots together. The syntax is <Library name>.<REL entry point name>(<arguments>). So let's assume you put your code in a Library called Custom_Email, your REL expression is:

[?=Custom_Email.GetJobParamaterTest('Test String')?]

It could be that you need to add an Action Subject on the Gateway.

If you want to move forward with the dynamic retrieval of the parameter your method will look something like this:

import com.redwood.scheduler.api.model.*;
import com.redwood.scheduler.api.scripting.variables.*;


public static String getJobParameter(Long jobId, String parameterName)
{
  SchedulerSession session = ScriptSessionFactory.getSession();
  Job j = session.getJobByJobId(jobId);
  if (j != null)
  {
    JobParameter jp = j.getJobParameterByName(parameterName);
    if (jp != null)
    {
      if (jp.getOutValue() != null)
      {
        return jp.getOutValue().toString();
      }
      return jp.getInValue().toString();
    }
  }
  return null;
}

Now you need to pass in the additional JobId, note that since the Job Id is a number, you don't need to add quotes:

[?=Custom_Email.GetJobParamaterTest(${JobId}, 'ParameterName')?]

Regards Gerben

Dallas1
Explorer
0 Kudos

Thanks Gerben, I finally got it working! I had a couple points that were holding me up:

#1 - In the REL, JobId does not need ${ } around it, as it's already in an REL expression, so that's a slight change from your example...

[?=Custom.GetJobParamater(JobId, 'EMAIL_CONTENT')?]

#2 - I was using getJobByUniqueId(..) instead of getJobByJobId(..). getJobByJobId(..) is the correct method, as you have in your code.

Job job = jcsSession.getJobByJobId(jobId);

Thanks much for your help! This is a nice solution to the problem.

Dallas