Episode 494: Variations of Data Processing at Automated Step (Part 1)

Monday, August 1, 2016
Processing a particular "Business data"
Converting a particular "Business data"
Retrieving the number of characters as a property of a particular "Business data"

Basically, a "Workflow system" automates "transactions" of Business data. I want to automate not only "transactions", but also "Tasks themselves" as far as possible.(To be unmanned) Especially, for "Mechanical routine"...

In "Questetra BPM Suite", a Cloud-based Workflow, using a feature of Auto-Step which has equipped originally, it is capable of server side processing, such as
  • To combine String A and String B (M227)
  • To sum Numeric A and Numeric B (M227)
  • To generate PDF file embedding strings to a Template PDF (M228)
  • To back up files tin Google Drive (M229)

However, it won't do for a "Processing that is more unique" even a little bit.

The "Character number counter" in the following Workflow is an automated Step that is, for example, to count the number of characters in String type data of X which has been entered at upstream Step, and to store the number into a Numeric type data item. (All done on the Server side) For such a case, you need to place a versatile Step which is referred to as [Script Step] (Script Task: M230), and to set a Script (ECMA-Script/JavaScript) into it. (as of version 11.0)

[Character Number Counter]

[Character Number Counter:"1. Document Set" screen]

The Script to be set here will be very short. It could be simple like
var countA = myText.length; 
if you imagined "part of counting characters" concretely. However, there might be uneasy cases where it should be counted as how many characters, in realistic business. It greatly differs according with its industry or business culture.
  • Reviewing of a treatise
  • Calibration on HTML
  • Reviewing on program
  • Reviewing on draught of press release

For example, how many should be the number of characters of the following strings counted as? (Showing double byte space as "_" for convenience)
12345678 0 
1234567 _0 

In many businesses, "line break" is not considered as a character. In some business, "Line-breaks or Consecutive spaces, etc., which entered for the legibility," are considered should not be counted as characters. For a draught in Japanese, "double byte spaces" and "single byte spaces" might be considered not to be counted.

After all, you need to determine "How to count characters" of your company beforehand.

= Setting Sample for Script Step "Character Number Counter" (Server side JavaScript)
//// == Retrieving == 
var myText = data.get("q_mytext") + ""; // JavaScript String 

//// == Calculating == 
var countA = myText.length; 
var countB = myText.replace(/\r|\n/g, "").length; 
var countC = myText.replace(/\r|\n/g, "") 
.replace(/\s+/g," ").length; 
var countD = myText.replace(/\r|\n/g, "") 
// Note) Tab and double byte space are included in "\s" (UTF-8) 

//// == Updating == 
retVal.put("4", java.math.BigDecimal( countA ) ); 
retVal.put("5", java.math.BigDecimal( countB ) ); 
retVal.put("6", java.math.BigDecimal( countC ) ); 
retVal.put("7", java.math.BigDecimal( countD ) ); 

= Example of implementation of "Character Number Counter" on the Browser side (HTML/JavaScript)
<span id="myCounter">0</span> 
<script type="text/javascript"> 
  jQuery('textarea[name="data[0].input"]').bind('keyup change',function(){ 
  var myTextLength = jQuery(this).val().length; 
  jQuery('#myCounter').html( myTextLength ); 

[Data Items list]

[Free Download]
<Similar Models>
<<Related Articles>>

[Japanese Entry (ε’Œζ–‡θ¨˜δΊ‹)]