Author Topic: Custom Table Script context  (Read 3976 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Custom Table Script context
« on: February 10, 2020, 08:16:15 pm »
Hello,


Anyone had a go at these custom table scripts?

I can create one and get it to execute, but what is its context?
That is, does it have a special variable representing the table? If not, how am I supposed to get at it?
Is there a magic way to interact with the two tags containing the table's format and content?
Does it have access to the full Object Model API? Are there any limitations compared to other scripts?
Can it reference another script? One packaged into an MDG Technology?


/Uffe
« Last Edit: February 10, 2020, 08:18:37 pm by Uffe »
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Custom Table Script context
« Reply #1 on: February 10, 2020, 11:35:03 pm »
No. My time as guinea pig is over...

q.

pianoman

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Custom Table Script context
« Reply #2 on: February 27, 2020, 07:32:50 am »
I'm interested in this as well. The Sparx Custom Table section found on
https://sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/custom_table_artifact.html
doesn't have anything meaningful written about scripts.

I don't know what scripts to write. Is it the same jscript ones I write in the Scripting window? Will it recognize commands like Repository.SQLQuery()? Am I supposed to shoot for the script to output data in .xml format? Array format?

The help page is entirely unclear about this and basically only mentions something to the effect of, "You can invoke a behavior script."

timoc

  • EA User
  • **
  • Posts: 201
  • Karma: +14/-0
    • View Profile
Re: Custom Table Script context
« Reply #3 on: February 28, 2020, 03:20:45 am »
I'm interested in this as well. The Sparx Custom Table section found on
https://sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/custom_table_artifact.html
doesn't have anything meaningful written about scripts.

I don't know what scripts to write. Is it the same jscript ones I write in the Scripting window? Will it recognize commands like Repository.SQLQuery()? Am I supposed to shoot for the script to output data in .xml format? Array format?

The help page is entirely unclear about this and basically only mentions something to the effect of, "You can invoke a behavior script."

I looked at it when it came out, but was dissapointed - it is a kind of cludgy. Think of it as a way of embedding table based information into an artifact for documentation. You are kind of limited to using the table manipulation tooling to make the table. You cannot import to or export from (except clipboard paste), so it is not even good for an embedded CSV source.

The underlying implementation is like an XHTML <table/> stored in a single SQL record - being a not invented here, the XML is not the global HTML standard for table and table formating, but their own XML markup (defined in the doc link).

You might be able to use some kind of SQLXML extensions to query it's contents, but i am not sure what for, because matinainting it as a source for anything looks like hard work.


pianoman

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Custom Table Script context
« Reply #4 on: February 28, 2020, 05:28:10 am »
Thanks timoc.

Was hoping I could muscle my way to making use of it like how MagicDraw allows the structure of tables that pull information from the model, and then update back to the model when you change the info on the table.

This seems far from it and simply stated seems like it will be limited to non-model data.

Robert van Egmond

  • EA Novice
  • *
  • Posts: 9
  • Karma: +3/-0
    • View Profile
Re: Custom Table Script context
« Reply #5 on: October 17, 2020, 01:17:13 am »
Hello,

I found something in a Youtube video introducing EA15.  https://www.youtube.com/watch?v=uEPP6ec9hVE at 23:35 they show an example of how to do this. You can enter the code for the script with by selecting the custom table and then Develop-->Source Code-->Behaviour-->Edit internal Code.  Here is the code snipped they use:

var theElement = Repository.GetElementByID(#OBJECTID#);
var theGrid = theElement.GetElementGrid();
var d = new Date();
var sVal =  d.toString();
theGrid.SetCell(0,1, sVal);
theGrid.Update();


Hope this helps!

Regards, Robert