Book a Demo

Author Topic: Dropdown list with EA scripts?  (Read 3616 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Dropdown list with EA scripts?
« on: June 11, 2020, 07:35:33 pm »
Hi,

I'm looking for a way to implement a script in EA that will start prompting the user to select a value from a downdown list (e.g. Select the class from the diagram to process: Class1, Class2...)
I know this is not possible with VBScript. Could JScript or even Javascript support it?

My client is using EA13.5, but a migration to the latest 15.1/.2 will eventually happen if there's something in the latest Javascript engine to achieve this.

Thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Dropdown list with EA scripts?
« Reply #1 on: June 11, 2020, 08:43:45 pm »
I think theoretically you could make a html page with a dropdown in it and get the value from there.

From a practical point of view, I've done something like this in scripts:

Code: [Select]
function getUserSelectedVersionControlID(package)
'check if the parent package has a version control ID
dim versionControlIDs
set versionControlIDs = getVersionControlIDsForPackages(package.ParentID)
if versionControlIDs.Count = 1 then
'return this one
getUserSelectedVersionControlID = versionControlIDs(0)
exit function
elseif versionControlIDs.Count = 0 then
'get all version control ID's in this model
set versionControlIDs = getVersionControlIDs()
end if
if versionControlIDs.Count <= 0 then
'no version control ID's here
exit function
end if
'build string
dim selectMessage
selectMessage = "Please enter the number of the configuration"
dim i
i = 0
dim versionControlID
for each versionControlID in versionControlIDs
i = i + 1
selectMessage = selectMessage & vbNewLine & i & ": " & versionControlID
next
dim response
response = InputBox(selectMessage, "Select Version control ID", "1" )
if isNumeric(response) then
if Cstr(Cint(response)) = response then 'check if response is integer
dim selectedID
selectedID = Cint(response) - 1
if selectedID >= 0 and selectedID < versionControlIDs.Count then
'return the version control ID
getUserSelectedVersionControlID = versionControlIDs(selectedID)
end if
end if
end if
end function
It's basically an inputbox that says

Please pick one of the following
1. Option1
2. Option2
3. Option3


It not as neat as a combobox, but it gets the job done just the same.

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Dropdown list with EA scripts?
« Reply #2 on: August 26, 2020, 05:25:31 pm »
Hi Geert,

Thanks for the info. I tried it and it works ok as a workaround.

Guillaume
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com