How to detect lifecycle event "ARTIFACT_OPENED" or "ARTIFACT_CLOSED" refers to a module?
The documentation is not very clear - does the event ARTIFACT_OPENED or ARTIFACT_CLOSED event relate to a module only or is there a way to detect the type of opened/closed artifact? Reason is the called function should only be executed when a user opens or closes a module.
|
One answer
OK, looking at some other example code from IBM I think it can be solved by the following.
// Subscribe to the ARTIFACT_OPENED event RM.Event.subscribe(RM.Event.ARTIFACT_OPENED, function(ref) { // Get the artifact attributes RM.Data.getAttributes(ref, RM.Data.Attributes.FORMAT, function(opResult) { // Check previous call completed OK if (opResult.code === RM.OperationResult.OPERATION_OK) { // Load an array with the attributes of the artifact var attrs = opResult.data[0]; // If the artifact is a module (the value of the attribute 'format' of the artifact is identical to that of a module) if (attrs.values[RM.Data.Attributes.FORMAT] === RM.Data.Formats.MODULE) { // call a function to do something with the module having handle 'ref' processModule(ref); } else { // it's not a module so do something else (or do nothing) with the artifact doSomethingElse(ref); } } }); }); |
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.