It's all about the answers!

Ask a question

Trigger on event in DOORS NG - how to detect Stream ID / Baseline ID on module open?


Adrian Haw (2741041) | asked Nov 02 '16, 10:10 a.m.
edited Nov 02 '16, 4:56 p.m.
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?


2 answers



permanent link
Dominic Tulley (38114) | answered Nov 07 '16, 12:02 p.m.
Hi Adrian,
The current client extension API does not have any visibility of the configuration the browser is currently operating in.

thanks
-Dominic

Comments
Adrian Haw commented Nov 07 '16, 2:39 p.m.

OK, thanks.


permanent link
Philipp Waldinger (1313) | answered Nov 07 '16, 2:34 p.m.
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:
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);
var currentConfiguration = "";
if (endOfConfigurationString != -1) currentConfiguration = currentURI.substr(startOfConfigurationString, endOfConfigurationString)
else currentConfiguration = currentURI.substr(startOfConfigurationString)
currentConfiguration = decodeURIComponent(currentConfiguration);
console.debug("Current Configuration: " + currentConfiguration);
There maybe are even better ways to get an GET Parameter inside an URL with Javascript, I only build this in a quick way.

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)
console.debug("Baseline Opened! ID: " + currentConfiguration.substring(indexOfBaseline + "baseline".length + 1));
else
console.debug("No Baseline Opened.");
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.

But at the moment and only to detect whether a baseline has been opened, it works...

Comments
Adrian Haw commented Nov 07 '16, 2:40 p.m. | edited Nov 07 '16, 2:42 p.m.

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.


Dominic Tulley commented Nov 14 '16, 10:42 a.m.

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..)

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.