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

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

 

We often receive the following sort of requests:
I would like to start work based on the contents of an email after receiving it!

[Message Start Event (Email)] enables to achieve the request!

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

e-mail-auto-start&analysis example

 

Among Questetra BPM Suite Users, this function has been relatively 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, copying and pasting it 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 way?”

 

We can do something about it!
In the case of a standard format, it can be realized with relatively simple JavaScript implementation.

== Email Body Example ==
Customer Name: Yamada Corporation

Since the refurbishment will be completed on May 4, 2013, please make drawings according to the specifications.
Delivery time is until December 20, 2013.

-- 
Questetra, Inc.
Masato Furukubo <furukub0@questetra.com> 
Branch Name: A Group Co., Ltd. Group Name: Construction group

If the email body consists of the following standard format:

  • Customer name is set following to the title character string “Customer name :”
  • Branch name is set following to the title character string “Branch name :”
  • Group name is set following to the title character string “Group name :”

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

== JavaScript Implementation Example ==
jQuery(document).ready(function(){
    // Retrieve process data item "Contents of Request"
    var text = jQuery('textarea[name="data[5].input"]').val();
    text = text.replace(/\r\n/g, "\n");
    var sep = ":";
    var line = new Array();
    line = text.split("\n");
    Analyze "Contents of Request" line by line and set it in 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"){
               jQuery('input[name="data[3].input"]').val(dat);
        }
        if (line[i].slice(0,pos)=="Branch name"){
               jQuery('input[name="data[21].input"]').val(dat);
        }
        if (line[i].slice(0,pos)=="Group name"){
               jQuery('input[name="data[2].input"]').val(dat);
        }
    }

});
※Wrap the code with script tag.

Paste the JavaScript Code into the Guide Panel type Process Data Item and set it as “Only display” in the property of the task you want to set automatically. That’s all!

In the task you do not auto-set, specify the Guide Panel type Process Data Item as “No display“.

== Implementation Example ==

email-analysis-example

Don’t you think it is relatively easy?
Since JavaScript implementation may reduce maintainability, we recommend that you use data with relatively unchanged format (Email body in this case).

Please make more and more use of [Message Start Event (Email)]!

※ Inquiries for JavaScript implementation are out of support scope.
※ Please feel free to consult with sales instead.

About Masato Furukubo

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

Recommendations
Prev article - 50. Questetra Tips What is Budget Management for Eliminating Over-budget Approval Request?
Next article - 50. Questetra Tips Analyzing the content of Email, Auto-setting based on it (Part 2)
Another article - Masato Furukubo Acquire the Storage Folder URL after Automatic Processing Step(Google Drive Integration)

Archive

 RSS