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

Calling a javascript function (dojo/ajax) when an RTC work item is saved in a certain state

I am trying to do some customization to an RTC work item.  When I move the work item to a certain state, and save it, I need to be able to invoke a java service running on a different machine through HTTP.  So, first question is how do I set things up to call a custom javascript when I save the RTC work item in a certain state.  I am assuming I can use dojo methods within the javascript function that I call.

0 votes

Comments

The question is also, what is the call supposed to achieve. Do you want to automatically set a calculated attribute?



2 answers

Permanent link
 Hello Tim,
pls refer to https://jazz.net/library/article/1003/#calc-values
then check https://jazz.net/library/article/1093
especially https://jazz.net/wiki/pub/Main/ProcessEnactmentWorkshop/20121122_ScriptBasedCustomization_Lab5_Solutions_Scripts.zip
where you'll find WorkFlowStateScriptedCalculatedValueProvider.js
which seems to correspond to your request:
(...)
var workFlowState = workItem.getValue(WorkItemAttributes.STATE);
debug("WorkflowState: " + workFlowState);

// Adjust attachment numbers in the code below
if(workFlowState=="") return "{{https://clm.example.com:9443/ccm/service/com.ibm.team.workitem.common.internal.rest.IAttachmentRestService/itemName/com.ibm.team.workitem.Attachment/1|New}}";
if(workFlowState=="tecReviewWorkflow.state.s1") return "{{https://clm.example.com:9443/ccm/service/com.ibm.team.workitem.common.internal.rest.IAttachmentRestService/itemName/com.ibm.team.workitem.Attachment/2|Proposed}}";
(...)

Hope it helps,
Eric

0 votes

Comments

Eric, you can not detect a state change that way. You can only detect the state you are in. So if a state change should trigger this, see below.

The only way to detect the state changes in JavaScript the community was able to come up with is like this.

  1. Add a hidden attribute and an attribute customization that depends on the state. If the state value of the hidden attribute is different from the state you read, write the new value to the hidden attribute.
  2. The other customizations trigger on the hidden attribute. Each time that changes they act.



Permanent link
I am not sure you can do this with attribute customization https://jazz.net/wiki/bin/view/Main/AttributeCustomization as the API seems to be quite limited. You would also have to use a hidden attribute to detect the state change. Howewer, I don't claim to be an expert.

The HTTP filtered value provider could be an option to access data on a server. See http://jorgediazblog.wordpress.com/2012/06/27/work-item-customization-httpconector-and-oauth-in-rtc-4-0-for-oslc/ for an example. https://jazz.net/library/article/1093 also shows some basics about attribute customization in Lab 5.

I also found https://jazz.net/forum/questions/84143/question-on-calling-a-service-from-rtc-webui which might be relevant in your case. I am however not sure this works in the context of JavaScript.

I assume you could also use the Chrome or Firefox debug mode to find out what JavaScript can be called in a script.

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

Question asked: Sep 25 '14, 1:03 p.m.

Question was seen: 4,887 times

Last updated: Sep 26 '14, 3:05 a.m.

Confirmation Cancel Confirm