Book a Demo

Author Topic: Creating an Action Element on a Diagram via VBScript  (Read 4672 times)

jdoody

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Creating an Action Element on a Diagram via VBScript
« on: November 06, 2018, 04:38:32 am »
I'm successfully adding a new Action element to a highlighted diagram in the project browser tree. I do this using the following VBScript culled from some examples in the community:
      
set newActionElem = thePackage.Elements.AddNew(thePackage.Name , "Action")
newActionElem.Update()

To make this a clickable action to a hyperlink I need to set the Advanced property of Kind to be a Hyperlink. When doing this manually, the Action is created using the type of Other and then selecting Hyperlink. I've tried various ways to set the Advanced property of Kind to a Hyperlink without success. It seems I need to create a sub element of type Hyperlink and add that to the Action element such as something like the following:

...Elements.AddNew "$inet://http://somesite.com" , "Hyperlink"

I'm not sure how to get that set to the Kind property.

I appreciate any assistance.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Creating an Action Element on a Diagram via VBScript
« Reply #1 on: November 06, 2018, 08:27:06 am »
I remember having answered that the last weeks, but where? Anyway, this is found in t_ref.Description:

Code: [Select]
@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=Hyperlink@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=value@ENDNAME;@TYPE=String@ENDTYPE;@VALU=www.sparx.com@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;

You need to create that entry in t_xref manually since there is (AFAIK) no API for it. Use Repository.Execute to send the CREATE SQL.

q.

jdoody

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Creating an Action Element on a Diagram via VBScript
« Reply #2 on: November 06, 2018, 08:48:47 am »
qwerty, Thanks. I did see some other posts in the forum, but I didn't see the correlation. I looked back at some and now I see it. I'll give the Custom SQL a look. Thanks for the quick reply.

John

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Creating an Action Element on a Diagram via VBScript
« Reply #3 on: November 06, 2018, 09:43:03 am »
You're welcome. If you run into any issue just come back here.

q.

jdoody

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Creating an Action Element on a Diagram via VBScript
« Reply #4 on: November 07, 2018, 05:54:49 am »
Here's an update on getting the t_xref row created. I struggled with an INSERT statement syntax error for a bit. It seemed funny that it was failing on the column named 'Partition'. Knowing this could be a reserved word, which it is, I had to modify the INSERT statement by adding some tick marks surrounding the word Partition. Following is an example if anyone every encounters this syntax issue:

INSERT INTO t_xref (XrefID, Name, Type, Visibility, `Partition`, Description, Client, Supplier) VALUES (....)

Once I added the tick marks the SQL ran successfully and the custom properties were created.

Thanks for the assistance.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Creating an Action Element on a Diagram via VBScript
« Reply #5 on: November 07, 2018, 07:24:47 am »
And the worst part is that these reserved words and the way you need to escape them differs from one SQL dialect to the other :-/ Anyhow, happy you finally solved it.

q.