Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.

0 votes



One answer

Permanent link
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);
            }
        }
    });
});

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,016

Question asked: Mar 28 '16, 5:52 a.m.

Question was seen: 2,164 times

Last updated: Mar 28 '16, 10:04 a.m.

Confirmation Cancel Confirm