Cloud Workflow

Analyzing the content of Email, Auto-setting based on it (Part 2)

Hi, there!

I wrote the post “Analyzing the content of an Email, and do Auto-setting based on it (Part 1)” before.
(Analyze the received email body with JavaScript and auto-set it into the Process Data Item)

Have you tried it?

We received a comment from a customer who did! (Thanks!)

“I’m in trouble because the auto-set content can be changed”

Exactly. (>_<)

Since JavaScript operates (analyzes Email → sets data) at the moment the task processing screen is opened, you need to configure the Process Data Item as “Editable”.
This setting can cause some operation trouble such as someone…

  • changing the Data Item by mistake (accidentally deleting it, for example)
  • Maliciously editing (Not good!)

What should we do…?
Oh right! We can deal with it by using a “Script Task” instead!

== Process Diagram using Message Start Event (email) and Script Task (Credit confirmation application) ==


※Normally, Script Task cannot be placed before the first task. However, it COULD be placed if the start event is an automatic start type event. (Convenient!)

Then, you only need to analyze the email body set by the Message Start Event (email) with Script Task!

== Script Task Implementation Example ==
var text = data.get("5");
text = text.replace("\r\n", "\n");
var sep = ":";
var line = new Array();
line = new String(text).split("\n");
var customerName = "";
var branchName = "";
var groupName = "";
// Analyze the "Request content" line by line and set them into Process Data Item
for(var i=0; i < line.length; i=i+1){
    var pos = line[i].indexOf(sep);
    var dat = line[i].slice(pos+sep.length);
    if (line[i].slice(0,pos)=="Customer Name"){
	customerName = dat;
    if (line[i].slice(0,pos)=="Branch Name"){
	branchName = dat;
    if (line[i].slice(0,pos)=="Group Name"){
	groupName = dat;

We can implement it with almost the same code as “JavaScript Implementation Example” introduced before.
However, to deal with the data from Process Data Item as String type, we need to convert it into the string type object explicitly as shown in the fifth line. (NOTE!)

line = new String(text).split("\n");
== Implementation Example (Task Processing Screen) ==


Don’t you think it is also relatively easy to implement it with Script Task?

Objects and Methods available for Script Task are listed in Manual (M230 AUTOMATED STEP Auto Executing Complicated Data Processing). Please refer to them and implement the Script.

I hope “Script Task” will help you extending the scope of use of Questetra BPM Suite more and more.

※In case you have difficulty implementing the Script, please feel free to contact our Sales team.

About Masato Furukubo

Questetra, Inc. Sales Department
View all posts by Masato Furukubo

Prev article - 50. Questetra Tips Analyzing the content of Email, Auto-setting based on it (Part 1)
Next article - 50. Questetra Tips How to Change Filenames Automatically following the Rule
Another article - Masato Furukubo How to Let a Robot Nominates Translators Randomly (3)