IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

Adding "default" value to Stereo type property #43

Closed leonAtRain closed 11 months ago

leonAtRain commented 1 year ago

Ask a question

I have a specific stereo type, that has a text field value, I want to populate the name of the Domain Model I apply the stereo type to - with a removeSuffix to appear as default in the text box, for example : image The ${Model.name} should be replaced by the Name.RemoveSuffix("Ref") result. How would I be able to achieve this? The reason I want it as a default - and not use the value in my Stereo type, is it is not always the case - about 90% of the time when I apply the stereo type, that would be the case, but other times, it might be for example : "AccountRef" - but then I want to point to "BillingAccount" instead... I would then like to be able to edit it.

JonathanLydall commented 1 year ago

Hi @leonAtRain,

At this time the only way this could be achieved is by having a designer extension which extends the Class element creating an On Changed script which would contain logic for checking the stereotype, its property and potentially changing the value.

For information on extending designers, you can refer to this article. In particular for this use case you would want to ensure you have an extension for Class with an On Changed script:

image

As for the script content, it would be something like:

var stereotype = element.getStereotype("ConfirmReferenceExists");
if (stereotype != null &&
    stereotype.getProperty("Service").getValue() === "${model.Name}")
{
    var value = removeSuffix(element.getName());
    stereotype.getProperty("Service").setValue(value);
}