Files Duplicate From Multi Items
Duplicates Files-type datas to Other Files-type data. All files stored in Files-type datas A is copied over Files-type data B
Configs
  • A: Edit Filed Names of Flie Type Items (Separator “,”) *
  • B: Select File DATA (update) *
  • C: Edit Prefix String For Copied File Name eg.”copied-“#{EL}
Script (click to open)
// GraalJS Script (engine type: 2)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){

//// == 工程コンフィグの参照 / Config Retrieving ==
const strFieldNames = configs.get( "conf_DataIdA" ); //required
const copiedFileItem = configs.getObject( "conf_DataIdB" ); //required
const strPrefix = configs.get( "conf_DataIdC" );

//// == ワークフローデータの参照 / Data Retrieving ==
const arryFieldNames = strFieldNames.split(",");
let prefix = strPrefix;
if (strPrefix === null){ prefix = ""; }

//// == 演算 / Calculating ==
let listFileObj;
const historyObjs = engine.findData( copiedFileItem );
if (historyObjs === null){
listFileObj = new java.util.ArrayList();
}else{
engine.log("historyObjs not null " + historyObjs.size());
listFileObj = historyObjs;
}

engine.log("arryFieldNames.length: " + arryFieldNames.length);
for (let i=0; i < arryFieldNames.length; i++){
let list = engine.findDataByVarName(arryFieldNames[i]);
if (list !== null){
engine.log("list.size(): " + list.size());
for (let j=0; j < list.size(); j++){
let orgQFileObj = list.get(j);
let newQFileObj = new com.questetra.bpms.core.event.scripttask.NewQfile(prefix + orgQFileObj.getName() , orgQFileObj.getContentType() , orgQFileObj);
listFileObj.add( 0 , newQFileObj );
}
}
}

//// == ワークフローデータへの代入 / Data Updating ==
if (listFileObj.size() !== 0){
engine.setData( copiedFileItem , listFileObj);
}else{
engine.log("Copied File is not exist.");
}

} //////// END "main()" /////////////////////////////////////////////////////////////////

Download

2022-06-19 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/files-duplicate-from-multi-items-202208/
The Addon-import feature is available with Professional edition.
Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.

Notes

  • Setup A: Provide the field name of the duplicate source File-type Data Item(s). (More than one is acceptable.)
    • Multiple items can be specified.
      • Enter the field name of the (File-type) Data Item to be duplicated, separated by commas “,”.
  • Setting C: (when storing duplicates) Please include the prefix of the file name. E.g. “copied-“
    • EL expressions can be entered.
      • Example: Setting “I#{#format(#q_inquiry_datetime, ‘yyyyMMddHHmm’)}-” Target file name: “Error screen capture.png”
      • Example output file name: “I202209121031-error-screen-capture.png”

Capture

Arrangement Tips

  • Delete source Data Item (File-type)
    • Set up an automatic data setting process and specify (a clear value) for the duplicate source Data Item.

See also

Leave a Reply

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

%d bloggers like this: