Question: how to set variables in Label Expression

Started by Xiaoqi, May 12, 2021, 03:25:26 AM

Previous topic - Next topic



Just new to using jArchi.

Searched on our jArchi wiki and forum here, not found the direct same question, so put a new here to seek your advice.

I'm using Archi to create lots of views, each view I give a View Name which I'm using Label Expression as $view{name} so that it's automatically link to the name I give to the view, this works fine as it's get from our pre-defined attribute.

While I'd also have another label willing to show the date I'm keep updating the view, e.g. "Updated at 2011/05/11", but I'd like this date can be having a way to fill in by script, no need to manually key in the data every time. (while, no need to keep refreshing that, so I'm thinking if there's a script that I can run and apply to the selected Label, and fill in the format in "Updated at yyyy/mm/dd" and the data is current date, that would be sufficient.)

I create one simple script as below:

* Objective: add Label to a view, and able to run and refresh the label text to the formate "updated at 2021/05/11", in which 2011/05/11 is the current date

current_datetime = new Date();
formatted_date = "Updated at " + current_datetime.getFullYear() + "/" + (current_datetime.getMonth() + 1) + "/" + current_datetime.getDate();


The script is OK of running and can display in console. But is there any method that I can link to the selected label? Maybe there's some attributes that I should use to call from this script, so when I select the blank label, I can execute the script and it's filled the line of text from code.

Thanks a lot,

Jean-Baptiste Sarrodie


I have something very similar. I'm using a property ("Last Update") attached to the view and references this property from the note's label ($view{property:Last Update}).

Then it's easy to update the view's property from a script (just make sure you selected the view before running the script).


If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.


Hi JB,

Thanks a lot, it's really simple way and working.

Following is the updaated script to deal with that "Last Update" property in the View:

current_datetime = new Date();
formatted_date = "Updated at " + current_datetime.getFullYear() + "/" + (current_datetime.getMonth() + 1) + "/" + current_datetime.getDate();

$(selection).prop("Last Update", formatted_date);


Have a nice day,