You are correct. EventData is the field to use. Here's an example  query (run from %SYS namespace):

SELECT UTCTimeStamp, EventSource, EventType, Event, EventData, Username, Description
FROM %SYS.Audit
WHERE (UTCTimeStamp BETWEEN '2018-10-27 00:00:00' and '2018-10-27 23:59:59') AND (EventData = '12345') AND (Namespace = 'ABC')
ORDER BY UTCTimeStamp DESC, SystemID DESC, AuditIndex DESC

You probably want to add a WHERE clause on the Namespace column. The docs for the %SYS.Audit class (https://docs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic....) suggest using a WHERE clause on UTCTimeStamp to speed up the search.

I think you are asking: "If I have an object open in one process, and another process updates that object or its corresponding row, what's the best way for the first process to make sure that it has the latest version of the data?"

I recommend using %Reload(). It makes it clearer to another developer what you're actually doing. A quick glance at the %Reload() code makes me think that it would be faster than killing the object and calling %OpenId() to reopen it.

Of course, you might want to make use of Concurrency options so that if you have an object open in one process, other processes are prevented from updating it.

This is not quite an answer to your question. Just some clarifications:

  • Your example is a %Query class query, where you write ObjectScript code for the query rather than using SQL. I haven't written one of those for a while. I'm assuming that ROWSPEC and CONTAINID are required for these types of class queries, but I'm not 100% sure.
  • A "newer" way to write a custom ObjectScript-based class query, using the class %SQL.CustomResultSet, doesn't require ROWSPEC either. Sample.CustomResultSet is an example of this technique.
  • For a %SQLQuery class query, written using SQL, ROWSPEC and CONTAINID have not been required for a loooong time. They are dynamically created from the query itself.

Regarding the user for Caché/Ensemble processes, the user for those is not always the user that starts/stops Caché/Ensemble. My instance of Ensemble runs on the Mac. For several years, I do a custom install so that I can change the answer to the 4th question below from cacheusr to joelsolon.

User who owns instance: joelsolon
Group allowed to start and stop instance: staff
Effective group for Ensemble processes: cacheusr
Effective user for Ensemble SuperServer: joelsolon

All the Ensemble processes run as OS user joelsolon because of this.

I don't actually have an answer to your question, but maybe these points will help.

It is possible to programmatically add a relationship to two persistent class definitions at runtime, and then compile those classes. That gives you the same result you'd get if you had added the relationship to the class definitions at design time. So I don't think that's what you want.

The term "Relationship" as defined in Caché means "objects of these classes can be linked at runtime, and this relationship will be stored when the objects are saved." So your need to create relationships between persistent objects "as and when they're required" doesn't really match up with this definition. Either a persistent class is in a relationship with another persistent class, or it isn't. It's not possible to have some objects of the class without the relationship definition, and other objects of the class with the relationship definition.

Maybe you just need to substitute one-many relationships for all of your parent-children relationships. One-many relationships are independent; the relationship is not required like it is in parent-children relationships. In v2013.1 and later, you can set the OnDelete action of the one-many relationship to "Cascade" so you get delete behavior similar to parent-children.

Here is some information about debugging CSP pages using Studio. I actually just taught this to students in class yesterday!

1. You can't set a breakpoint inside the ObjectScript on a CSP page (inside a <script> tag). But the workaround for this is to use the View > View Other Code and load the class definition that's generated from the CSP page. Then you can set breakpoints normally.

2. Once you've set breakpoints, you can set your CSP page as the Debugging Target, and launch it directly from Studio. The page runs in a special "debug mode". This means that the normal timeouts (typically 60 seconds) are suspended, so that the browser and the CSP Gateway will wait as long as necessary while you step through the code.

You can step through the code that is called when the page is first being built, and you can also step through code that is called via a hyperevent.

The only issue with stepping through the code is that Studio does not seem to be highlighting the current line as it normally does. I think this used to work fine, so I may bring this up with the developers. But a workaround for now is to use the "Call Stack" tab of the Watch Window. The top line of the call stack shows the label+offset of the current line. As you step, the top line is updated with the current label+offset. You can simply click the top line whenever you want and the Code Window will scroll to that line, also showing you the current values of the variables.

I never updated this post with the workaround, sorry! The problem is with Secure Storage. You can reset it by going into Atelier > Preferences > General > Security > Secure Storage. Click the Contents tab. Under com.intersys.eclipse.connmgr, you'll see an entry for the connection to the Caché server. Delete that entry, and you should be able to recreate the server connection.