Trigger on event in DOORS NG - how to detect Stream ID / Baseline ID on module open?
![](http://jazz.net/_images/myphoto/b877c5d2105bf97315edd483717b4a2a.jpg)
Following on from a previous question ( https://jazz.net/forum/questions/226617/how-to-deploy-a-trigger-on-gui-andor-server-event-on-doors-ng ) where we see how to trigger a script when a module is opened....
When the project containing a module is config-enabled, how to detect the context (Stream ID / Baseline ID) in which the module is opened?
Is it possible to restrict the trigger so that the event only happens in a stream (editable version) and not a baseline (read-only version) or is there another method to detect the module version being opened is editable by the user?
When the project containing a module is config-enabled, how to detect the context (Stream ID / Baseline ID) in which the module is opened?
Is it possible to restrict the trigger so that the event only happens in a stream (editable version) and not a baseline (read-only version) or is there another method to detect the module version being opened is editable by the user?
2 answers
![](http://jazz.net/_images/myphoto/b877c5d2105bf97315edd483717b4a2a.jpg)
As Dominic mentioned, the API does not support Configurations at the moment. And I also don't know a way to get this information with the REST API (but I'm no expert with it).
So as far as I see, there currently is no supported, safe and stable way to access this information.
You propably should not and do not want to use a unsupported, unsafe and unstable way to get this information. But...
The configuration in which an artifact is opened is part of the URL displayed in the browser window. To be precise, the GET Parameter "vvc.configuration" contains the URL of the configuration which is currently used.
To get this parameter and its value, you have to break out of the iFrame in which your widget is locked and obtain the URL from the main window object:
And then (now it's getting even more ugly), to determine whether you opened a baseline, you can take advantage of the fact that the configuration URL contains the word "stream" if it points to a stream, and "baseline", if it points to a baseline.
So:
But at the moment and only to detect whether a baseline has been opened, it works...
So as far as I see, there currently is no supported, safe and stable way to access this information.
You propably should not and do not want to use a unsupported, unsafe and unstable way to get this information. But...
The configuration in which an artifact is opened is part of the URL displayed in the browser window. To be precise, the GET Parameter "vvc.configuration" contains the URL of the configuration which is currently used.
To get this parameter and its value, you have to break out of the iFrame in which your widget is locked and obtain the URL from the main window object:
var currentURI = parent.window.location.href;And as soon as you got the URL, the rest is common string logic with javascript to isolate the configuration-parameter:
var startOfConfigurationString = currentURI.indexOf("vvc.configuration=") + "vvc.configuration=".length; var endOfConfigurationString = currentURI.indexOf("&", startOfConfigurationString);There maybe are even better ways to get an GET Parameter inside an URL with Javascript, I only build this in a quick way.
var currentConfiguration = "";
if (endOfConfigurationString != -1) currentConfiguration = currentURI.substr(startOfConfigurationString, endOfConfigurationString)
else currentConfiguration = currentURI.substr(startOfConfigurationString)
currentConfiguration = decodeURIComponent(currentConfiguration);
console.debug("Current Configuration: " + currentConfiguration);
And then (now it's getting even more ugly), to determine whether you opened a baseline, you can take advantage of the fact that the configuration URL contains the word "stream" if it points to a stream, and "baseline", if it points to a baseline.
So:
var indexOfBaseline = currentConfiguration.indexOf("baseline"); if (indexOfBaseline != -1)There might be special cases in which this does not work. It can get broken by any future IBM update or changes to the way URLs are build. Also, you can not really do anything with the information you gather this way (beside displaying a link to the configuration or detect whether you are inside of a Baseline): I am not aware of any way to get more information about a configuration if you have its URL, neither with REST nor with the javascript API.
console.debug("Baseline Opened! ID: " + currentConfiguration.substring(indexOfBaseline + "baseline".length + 1));
else
console.debug("No Baseline Opened.");
But at the moment and only to detect whether a baseline has been opened, it works...
Comments
![](http://jazz.net/_images/myphoto/b877c5d2105bf97315edd483717b4a2a.jpg)
Interesting. Thanks for your effort in replying so fully.
Looks like I'm going to have to submit enhancement requests - there seems to be no useful support for scripting wrt Global/Local Configs & Streams.
![](http://jazz.net/_images/myphoto/c61b817e81e4207c10fc77bc0e161bb7.jpg)
Just a quick caveat on Philipp's response above - what he has said is NOT always true (no doubt depends exactly which version of RDNG you are running..)