It's all about the answers!

Ask a question

How to deploy a trigger on GUI and/or Server event on DOORS NG ?


Joseph Aracic (2716) | asked Aug 11 '16, 4:00 a.m.
 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


permanent link
Philipp Waldinger (1313) | answered Aug 11 '16, 7:44 a.m.
edited Aug 30 '16, 4:14 a.m.
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:
  1. Subscribe to the ARTIFACT_OPENED event: 
    RM.Event.subscribe(RM.Event.ARTIFACT_OPENED, yourFunction(openedArtifact)); 

  2. In yourFunction, get the artifact format attribute of the opened artifact: 
    RM.Data.getAttributes(openedArtifact, [RM.Data.Attributes.FORMAT], yourSecondFunction(result)) 

  3. 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:
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!"); }); });
The following events are currently available:
  • ARTIFACT_SELECTED
  • ARTIFACT_OPENED
  • ARTIFACT_SAVED
  • ARTIFACT_CLOSED
Joseph Aracic selected this answer as the correct answer

Comments
Joseph Aracic commented Aug 11 '16, 12:16 p.m.

 Thanks you Philipp, Very useful.


Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.