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

How to Trigger code in DNG.

Hi,

 
When we edit module in DNG it is automatically saves after focus lost. If I want to execute other functionality on save then is it possible to do that? If yes, how can I do that.  Any help would greatly appreciated. 

0 votes

Comments

Do you want to execute some functionality in addition to or instead of the save? 

Do you want your code to be executed in any case (so the user cannot disable it, e.g. to enforce some policies), or is it ok if the user can enable and disable it (e.g. for some convenience functionalities)? 


Accepted answer

Permanent link

You can use the Javascript API to execute some javascript code as soon as one of the available events is triggered (ARTIFACT_SELECTED, ARTIFACT_OPENED, ARTIFACT_SAVED, ARTIFACT_CLOSED).

To use this API, you have to gain access to the Javascript RM Object - which first of all is available only in widgets.
Maybe there are also possibilities to access this object from outside widgets (e.g. in javascript code which you included using a Theme).
If you only use a widget, the user must first add it to the sidebar in order to activate your functionality.

You can find the Javascript API Documentation here:

In this topic:
I posted a short code example which executes some javascript as soon as a module is opened:
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!"); }); });

Following this schema, this could be adapted in a way to be executed as soon as an artifact is saved.

You can then either implement your desired business logic directly in Javascript, or trigger some other code e.g. in a Server Application.

Jayshri Burde selected this answer as the correct answer

1 vote


One other answer

Permanent link

As far as I know you can not extend DNG to be able to do that, unfortunately. 

0 votes

Comments

Correct, you cannot extend or configure the web UI or server side code to do that.
What kind of functionality do have in mind?

Maybe I do not understand the question correctly, but what if you use a widget with some javascript which is executed when the ARTIFACT_SAVED lifecycle event is triggered (see section »Lifecycle events« in https://jazz.net/wiki/bin/view/Main/RMExtensionsAPI602 )? 

You cannot prevent saving this way (because the event is triggered after the save operation), but I read the question like if some other functionality in addition to the save is demanded.

 Yes Philipp,

I want to add additional functionality on save.

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
× 10,938

Question asked: Feb 24 '17, 5:40 a.m.

Question was seen: 2,338 times

Last updated: Feb 27 '17, 10:40 a.m.

Confirmation Cancel Confirm