The Group.ModelList() shows some odd behavior. It cannot find a model (by name) when the name ends like ' 2013-2'. Mind the blank! It does find the model when the number is preceded or followed by a non-numeric character (p.e. ' a2013-2). The Find function in the designer (explorer) shows the same behavior. But there you can escape the hyphen with a backslash. That does not work in a report script. The only solution seems to be to replace the '-' with a '?' (wildcard), but that leaves some room for unwanted results (not much, but still..).

The example below searches for the model in its own Group and only finds the model when the hyphen is replaced (the line with the replace uncommented). I used modelname '3D Xoffice v_ 2013-3' for my test. We are running ARIS 9.7 on JAVA 1.7.

Is this a genuine bug, or am I missing something?

Does anyone have a better solution?

------

var gLocale = Context.getSelectedLanguage();                                 
var currentDatabase = ArisData.getActiveDatabase();
var sourceModel = ArisData.getSelectedModels()[0];
function main() {
    var searchGroup =  sourceModel.Group();
    var modelName = sourceModel.Name(gLocale);
//    modelName = modelName.replace("-", "?");
    var searchArg = currentDatabase.createSearchItem(Constants.AT_NAME, gLocale, modelName, Constants.SEARCH_CMP_EQUAL, false, true);
    var findResult = searchGroup.ModelList(true, [sourceModel.TypeNum()], searchArg);
    if (findResult.length == 0) {
        Dialogs.MsgBox("The model " + modelName + " NOT found.");
    }
    else {
        Dialogs.MsgBox("The model " + modelName + " found.");
    }       
}
main();

 or register to reply.

Notify Moderator