Author Topic: How to change the Parameter Type in ActivityParameters elements via Script  (Read 6526 times)

pb17

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Hello everyone,

I'm working on a script to automate the updating of Parameter Type in the ActivityParameter Elements. These can be set to types such as "String", "Integer", "Real", (...) "<none>".

I'm specifically trying to set it to '<none>', but I'm having trouble accessing this element Parameter via script. Does anyone have any tips or know how to accomplish this?

Thank you in advance

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to change the Parameter Type in ActivityParameters elements via Script
« Reply #1 on: September 20, 2024, 11:02:47 pm »
Looks like it's part of the custom properties.

It's stored in t_xref in the description field like this:
@PROP=@NAME=default@ENDNAME;@TYPE=String@ENDTYPE;@VALU=bla bla@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=isConst@ENDNAME;@TYPE=Boolean@ENDTYPE;@VALU=True@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=isStream@ENDNAME;@TYPE=boolean@ENDTYPE;@VALU=0@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=isException@ENDNAME;@TYPE=boolean@ENDTYPE;@VALU=0@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;

I'm pretty sure you can access values using EA.Element.CustomProperties

Geert

Elpis

  • EA User
  • **
  • Posts: 42
  • Karma: +6/-0
  • Make MDA/MBSE vital.
    • View Profile
Re: How to change the Parameter Type in ActivityParameters elements via Script
« Reply #2 on: September 23, 2024, 07:45:28 pm »
Looks like it's part of the custom properties.
[...]
I'm pretty sure you can access values using EA.Element.CustomProperties

But documentation on https://sparxsystems.com/enterprise_architect_user_guide/17.0/add-ins___scripting/element2.html states:
"Currently only editable from the user interface."
so updating the value (here: to "<none>") might be impossible this way.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to change the Parameter Type in ActivityParameters elements via Script
« Reply #3 on: September 23, 2024, 08:29:15 pm »
Yes, it looks that way.

If I were you, I would test for the value using the customproperties, and then use an SQL update statement to change the value.

You can use the undocumented method Repository.Execute(sqlUpdateString) to execute your update.
Be careful however to not break things. Repository.Execute is like playing with matches in a room full of fireworks.

Geert

pb17

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: How to change the Parameter Type in ActivityParameters elements via Script
« Reply #4 on: September 26, 2024, 06:53:52 pm »

Hi Greet!
Thank you so much for the feedback.
Sorry for the delay in my response.
I´ve tried to iterate and get the information for the custom properties, but none has this information.
I can get the information about the:
Code: [Select]
isStream
 isException
 default
 effect
 direction
 isConst
 isOrdered
 isUnique
 isControlType
It looks like it is not possible to update via script.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to change the Parameter Type in ActivityParameters elements via Script
« Reply #5 on: September 26, 2024, 07:51:48 pm »

Hi Greet!
It Geert, not Greet
Quote
It looks like it is not possible to update via script.
If you look at the customproperties of the Activity, you'll find the types of the parameters.
How exactly this ties tot he ActivityParameters; I haven't figured out.

Updating is possible in a script, but you'll need to use Repository.Execute

Geert



pb17

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: How to change the Parameter Type in ActivityParameters elements via Script
« Reply #6 on: September 26, 2024, 11:18:19 pm »
I apologize for the mistake. I have dyslexia, and it's something I struggle with.
I will take a closer look at the custom properties of the activity.
Thank you again for your support!