BR
Hi
I'd like to set the title of the report to be the selected subprocess name, if there is only one selected subprocess, or to be the process name, if there is more than one subprocess selected. Is this possible?
At the moment the title of the report is set to be the script name, which I understand is the default.
Thank you in advance for your help.
Bruno Rocha
Hi, this is totally possible.
Here is how I would do it (note: this is crudely written - you may be able to improve it)
var nLocale = Context.getSelectedLanguage(); //get the Locale id
var modelsArray = ArisData.getSelectedModels(); //get the selected models
var futureFileName = null; //placeholder variable for the future script name
if (modelsArray.length == 1) { //if only one model has been selected
futureFileName = modelsArray[0].Name(nLocale); //found the future file name (without file extension)
} else if (modelsArray.length > 1) { //else if multiple models have been selected, try to find the superior model that contains occ of objdef which have the sub processes assigend
var potentialSuperiorModels = null; //placeholder for an array that'll contain multiple superior objects
for each (var modelsArrayElement in modelsArray) { //go through all selected models
if(potentialSuperiorModels == null) { //if it's the first model we're checking
potentialSuperiorModels = getUniqueSuperiorModels(modelsArrayElement); //set the superiorModelsArray to the superior models of the current model
} else { //otherwise
potentialSuperiorModels = getUniqueIntersection(potentialSuperiorModels, getUniqueSuperiorModels(modelsArrayElement)); //get the intersection of all the models that contain the found superior models so far and the superior models of the current model
}
}
if(potentialSuperiorModels != null && potentialSuperiorModels.length == 1){ //if only one superior model remains
futureFileName = potentialSuperiorModels[0].Name(nLocale); //found the future file name (without file extension)
}
}
if (futureFileName != null) { //if the future file name (without file extension) was found
//set the future file name - don't forget to append the file format (e.g. .txt, .pdf, .doc)
//you can implement this yourself
}
function getUniqueSuperiorModels(model) { //function to find the superior models of a model
var resultArray = [];
for each (var superiorObjDef in model.getSuperiorObjDefs()) {
for each(var superiorObjDefOcc in superiorObjDef.OccList()) {
resultArray.push(superiorObjDefOcc.Model());
}
}
return ArisData.Unique(resultArray);
}
function getUniqueIntersection(arrayA, arrayB){ //find the intersection of two arrays containing elements of the Aris class Item - in this script it's only used for objects of the type Model, which inherits from Item the IsEqual method
var resultArray = [];
arrayAIteration:
for each (var arrayAElement in arrayA) {
for each(var arrayBElement in arrayB) {
if(arrayAElement.IsEqual(arrayBElement)) {
resultArray.push(arrayAElement);
continue arrayAIteration;
}
}
}
return ArisData.Unique(resultArray);
}
If you have any questions about the script or how to approach such a problem in general, feel free to ask. I added comments to most of the lines of the script, trying to explain what it does in English.