Archi Forum

Archi Plug-ins => jArchi => Topic started by: rheward on March 09, 2023, 15:38:04 PM

Title: Label expressions are not supported for data-object
Post by: rheward on March 09, 2023, 15:38:04 PM
I'd like to create an object, add a property, then set its Label Expression. It's the Label Expression that fails..

Create a data-object called Bill and add a property called "AltName", value Fred.

var obj = $(".Bill").first();
console.log(obj.prop("AltName"));
obj.labelExpression = "Joe";
//obj.labelExpression = "${property:AltName}";


I'm getting:

Fred
javax.script.ScriptException: com.archimatetool.script.ArchiScriptException: Label expressions are not supported for data-object: Bill

I think I'm referencing the wrong kind of object?  :-[

If I do in a loop, it's fine (but I want to do it for the new one I've just created.

selection.filter('element').each(function(e) {
    e.setLabelExpression("${property:AltName}");   
})

Title: Re: Label expressions are not supported for data-object
Post by: Phil Beauvoir on March 09, 2023, 15:46:19 PM
Hi, label expressions can only be set on visual objects in a View, not concepts. Your first example is returning a concept.
Title: Re: Label expressions are not supported for data-object
Post by: rheward on March 09, 2023, 16:37:19 PM
Ah, of course. Makes sense now. I was trying to default it for when it does become a visual object.