Parsing the Content of Email and make Automatic Settings Based on It
Introducing how to automatically Start a Process by receiving an email, and to input the data into Data Items automatically by parsing the contents of the email.

Hi there,
This time I will talk about the implementation of simple JavaScript.

We often receive the following sort of requests:
“I would like to start work based on the contents of an email that has been received!”

This can be achieved using the [Message Start Event (email)]!

Process diagram using the [Message Start Event (Email)] (Credit confirmation application)

*Normally, a Script Task cannot be placed before the first Human Task. However, it can be placed if the start event is an automatic start event. (Convenient!)

Among Questetra BPM Suite Users this function is relatively well known.
By retrieving Email from systems other than Questetra BPM Suite, system coordination can be implemented easily.

You will be free from boring tasks such as receiving prosaic emails, and copying and pasting them into another system.

However, we also hear requests from some Questetra BPM Suite Users like

“We automatically import order notification emails from mission-critical systems into Questetra BPM Suite and process them. It’s handy, but very troublesome to copy and paste customer names, order amounts, etc. into the input form from the body of the email! Couldn’t you find some other way?”

We can do something about it!
In cases where the email has a standard format we can deal with it by using a Script Task

Email Body Example

Customer Name: AAA Corporation

Since the refurbishment will be completed on May 4, 2019, please make drawings according to the specifications.

Delivery time is until December 20, 2018.
— 
Questetra, Inc.
Jack Brown <jack-b@example.com>
Branch Name: East branch Group Name: Construction group

If the email body consists of the following standard format:

  • The title string “Customer name:” is followed by the customer name.
  • The title string “Branch name:” is followed by the branch name.
  • The title string “Group name:” is followed by the group name.

You just need to search the title string, get the string following it, and set it in the Process Data Item form.

Script Task Implementation Example

var text = engine.findDataByNumber("15");
text = text.replace("\r\n", "\n");
var sep = ":";
var line = new Array();
line = new String(text).split("\n");
var customerName = "";
var branchName = "";
var groupName = "";
// Parse 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;
    }
}
engine.setDataByNumber("17",customerName);
engine.setDataByNumber("12",branchName);
engine.setDataByNumber("11",groupName);

To deal with the data from Process Data Items as a string we need to convert it into a String-type object explicitly, as shown in the fifth line.

line = new String(text).split("\n");

Implementation Example (Task Processing Screen)

 

Don’t you think it’s relatively easy to implement? Objects and Methods that can be used in the 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 Tasks will help you to extend the scope of use for Questetra BPM Suite more and more.

1 thought on “Parsing the Content of Email and make Automatic Settings Based on It”

  1. Pingback: RPA is Not the Only Automation! Various Examples of Automation by Cloud-based Workflow - Questetra

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d