Comments

Comment by Kay Fischbach

Posted on 2018-07-20

Basically what you want to do is replace the null in your Designer.getAttribute call with an object of the type Language. Sounds simple, doesn't it? Well it isn't. Here is an example of what I came up with (Macro context: only object definitions of type Org Unit, it should work with other object definitions (like the ones you picked with your BrowseArisItems() method) too).

var p_selObjDef = Context.getSelectedObjects(); //Get the selected Object Definitions
main(); //Just a habit of mine, don't want to clutter the global namespace
function main(){ //see previous point
for each (var selObjDef in p_selObjDef){ //for each selected Object definition
var languageGerman = getLanguageWithLocale(selObjDef, java.util.Locale.GERMANY); //calls a self built opposite method of Designer.toLocale(language), that transforms a field of java.util.Locale back into an ARIS Object of the type Language
var languageUS = getLanguageWithLocale(selObjDef, java.util.Locale.US); //see previous point
if((languageGerman != null) && (languageUS != null)){ //if both Language objects are available now
Context.MsgBox("German name attribute: " + Designer.getAttribute(selObjDef, Constants.AT_NAME, languageGerman).getPlainText() + "\nEnglish name attribute: " + Designer.getAttribute(selObjDef, Constants.AT_NAME, languageUS).getPlainText()); //Open a dialog with some data to show that it works
}
}
//This is where the fun begins
function getLanguageWithLocale(selObjDef, localeField){ //A method that can use an object definition (or anything else that has ties to the login, only tested it with object defs though) and a field of java.util.Locale, to find an ARIS Object of the type Language
var loginInfo = Context.getLoginInfo(selObjDef); //Get information about the current login
var curDatabase = loginInfo.getDatabase(); //get the database the user is currently logged into
var allLanguages = Designer.getAllDBLanguages(curDatabase); //get all available languages for this database
for each (var oneLanguage in allLanguages){ //iterate through all allowed Languages
var localeLanguage = Designer.toLocale(oneLanguage); //Transform the language into an java.util.Locale object, for comparisons sake
if(localeLanguage.equals(localeField)){ //if the locale we are currently viewing matches the one we gave the method through the field
return oneLanguage; //return the Language object from which we obtained the Locale object
}
}
return null; //if you can't find any matching Language, return null to make this noticeable
}
}

If you have any additional questions, need more clarification/explanation, or are just confused af, feel free to reply. I'll see what I can do.