How to deploy a trigger on GUI and/or Server event on DOORS NG ?
Hi,
My first concern now is to be able to run automatically a javascript when a user open a DNG document.
A "trigger" that execute a widget could be the right way to do that, but I found no trace of that in https://jazz.net/wiki/bin/view/Main/RMExtensions602
May be it is something that is more "buried" in JAZZ (something like a trigger on Work Items events). I'm not a JAZZ expert, and I have not found any documentation related to that.
I'm quite sure that I heard a IBM application Engineer has said that is is at least possible to deploy a trigger in DNG based on a user(GUI) event.
Actually, the "Trigger" is a great weapon to enforce a workbench, I would be surprized that Jazz platform does not provide an equivalent mechanism.
I use :
- Jazz Foundation - Core Libraries V 6.0.1 (but soon the last one)
- Rational DOORS Next Generation V 6.0
Does someone can help me ?
Thanks in advance.
Accepted answer
If I understand your question right, you want to run a javascript as soon as an artifact with format module is opened.
Assuming you have access to the javascript RM Object (e.g. in a widget), you could try the following:
-
Subscribe to the ARTIFACT_OPENED event:
RM.Event.subscribe(RM.Event.ARTIFACT_OPENED, yourFunction(openedArtifact));
-
In yourFunction, get the artifact format attribute of the opened artifact:
RM.Data.getAttributes(openedArtifact, [RM.Data.Attributes.FORMAT], yourSecondFunction(result))
-
In yourSecondFunction, check whether the artifact type is RM.Data.Formats.MODULE:
result.data[0].values[RM.Data.Attributes.FORMAT] == RM.Data.Formats.MODULE
If this is the case, a module has been opened.
Now you can call another function or directly place your code here.
Of course you could or should use anonymous functions instead of yourFunction() or yourSecondFunction().
You also should check whether the getAttribute operation finished successfully before you access the result (result.code == RM.OperationResult.OPERATION_OK).
Putting it all together, this should work:
The following events are currently available:RM.Event.subscribe(RM.Event.ARTIFACT_OPENED, function(openedArtifact){
RM.Data.getAttributes(openedArtifact, [RM.Data.Attributes.FORMAT], function(result){
if(result.code != RM.OperationResult.OPERATION_OK)
console.error("Could not retrieve attributes of opened artifact!");
else if(result.data[0].values[RM.Data.Attributes.FORMAT] == RM.Data.Formats.MODULE)
console.debug("Module opened!"); }); });
- ARTIFACT_SELECTED
- ARTIFACT_OPENED
- ARTIFACT_SAVED
- ARTIFACT_CLOSED
Please also refer to Client Extension API for the Requirements Management (RM) Application.