Book a Demo

Author Topic: GUID Parameter of EA_OnNotifyContextItemModified (Model Addin)  (Read 5157 times)

potterm

  • EA User
  • **
  • Posts: 126
  • Karma: +0/-0
    • View Profile
I'm trying to use the EA_OnNotifyContextItemModified addin event inside a model addin (i.e. in Javascript), but am having issues with the GUID parameter.  The script engine isn't recognising it as a string.  Is this a bug or am I missing something?  In the reception definion for the signal it's defined to be a string so I can't see what I could possibly be doing wrong.

For example, I can't even get the following simple line of code (in EA_OnNotifyContextItemModified) to work:

Code: [Select]
Session.Output(GUID);

This returns an error in the Addin Script Output window as follows:

Code: [Select]
Invocation error in: addin.EA_OnNotifyContextItemModified
------------------------------------------------
 238:   
 239:    Session.Output(GUID);
 240:                 [!!!! Parameter 13531608 type mismatch]
--------------------------------------------------

Variations such as GUID.valueOf() and GUID.toString() don't work either (they just return "[object Object]" instead).

Thanks in advance.
Martin

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: GUID Parameter of EA_OnNotifyContextItemModified (Model Addin)
« Reply #1 on: May 08, 2021, 04:27:16 pm »
Marin,

You might want to share he whole actual code. No we can only guess what this GUID variable contains, or where it came from.
It looks like it contains an object of some kind of object.
You might have mixed up the parameters or something

Geert

potterm

  • EA User
  • **
  • Posts: 126
  • Karma: +0/-0
    • View Profile
Re: GUID Parameter of EA_OnNotifyContextItemModified (Model Addin)
« Reply #2 on: May 08, 2021, 09:49:49 pm »
Thanks Geert.  Pretty sure I'm not mixing the parameters up - the signature for the signal (per the EA documenation, also in-model when you import the signals to create the Addin) shows GUID as being of type "String".  The code is simply what I posted before - a single line with the Session.Out statement.  I suspect it is a bug, with EA not marshalling the object properly to the Javascript Addin framework.  There's no other explanation really.

If I knew what type of object it was and what the properties were then I could perhaps work around it....

Martin

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: GUID Parameter of EA_OnNotifyContextItemModified (Model Addin)
« Reply #3 on: May 09, 2021, 04:16:58 pm »
Allright. I never actually used the Model Addins as I have my own alternative for years now (EA-Matic)

Make sure to send in a bug report then, so Sparx can have a look at it.

Geert

potterm

  • EA User
  • **
  • Posts: 126
  • Karma: +0/-0
    • View Profile
Re: GUID Parameter of EA_OnNotifyContextItemModified (Model Addin)
« Reply #4 on: May 10, 2021, 03:28:49 pm »
Thanks Geert.  Bug report raised.

potterm

  • EA User
  • **
  • Posts: 126
  • Karma: +0/-0
    • View Profile
SOLVED: GUID Parameter of EA_OnNotifyContextItemModified (Model Addin)
« Reply #5 on: May 10, 2021, 08:37:01 pm »
I've raised the bug report anyway, but in the meantime have discovered (by examining the object passed in using Javascript introspection features) that it contains a property "val" and that this provides the GUID value.  So...

Code: [Select]
Session.Output(GUID.val);
now works :)

Hopefully of use to anyone else struggling with the same issue.

Martin
« Last Edit: May 10, 2021, 10:41:07 pm by potterm »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: GUID Parameter of EA_OnNotifyContextItemModified (Model Addin)
« Reply #6 on: May 17, 2021, 09:21:38 am »
Yes, all arguments that are passed by reference in the interface are wrapped in an object to allow Javascript to pass a value back.

https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/automation/modeladdins-code.html