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

How to get value of attribute in Java based calculated value provider plug-in

 Hi All,

Developing Java based Calculated Value Provider plug-in to integrate RTC with external application through REST APIs. Need to get value of the attribute and send it to external application through REST API. The problem is that the getValue(IAttribute) API of WorkItem returns empty when workitem created in WebUI however the same work when workitem created in EclipseUI. It works when Workitem Save button is pressed in WebUI. However it does not when dependency triggered. 

Not sure why this change in behaviour while working WebUI & EclipseUI. It appears that script is needed to make it work with WebUI but how to integrate Script and Java method?. 

If not is there way to consume REST APIs in calculated value provider script?. I do not see any such support as HTTPConnect facility limited to Validator only. 

Please suggest. Thanks in advance!.

0 votes

Comments

 Here is the sample code am trying

public class GetSummary implements com.ibm.team.workitem.common.internal.attributeValueProviders.IValueProvider<Object> {

@Override
public Object getValue(IAttribute attribute, IWorkItem workItem,
IWorkItemCommon workItemCommon, IConfiguration configuration,
IProgressMonitor monitor) throws TeamRepositoryException {
// TODO Auto-generated method stub
return workItem.getHTMLSummary().getPlainText();
}

}


Accepted answer

Permanent link

 This works as designed, when using a Java based Calculated Value Provider, the provider gets triggered only on Save and not when it is dirty, however when using a script based value provider, it gets invoked when the work item is dirty because the script is loaded in the browser.

Mallanagouda Patil selected this answer as the correct answer

0 votes

Comments

Hi Shroon,
Same issue with script based value provider as well.
var summaryValue=workItem.getValue(WorkItemAttributes.SUMMARY);
      console.log("Get Summary Value : " +summaryValue);
The above API returns empty though text has been entered in Summary attribute. The same issue with String type attribute as well.
But works with enumeration or integer attributes

var severity= workItem.getValue(WorkItemAttributes.SEVERITY);
console.log("Severity value is " +severity);

https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Calculated_values
As per above article, it suppose to work for String, Integer and other attributes as well.
Is there any change in 6.0.1?. I had developed calculated value provider scripts in 5.0.1 for computation purpose and it had worked.

/sample script/
dojo.provide("com.example.getsummaryvalue");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
    var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
    dojo.declare("com.example.getsummaryvalue", null, {
        getValue: function(attribute, workItem, configuration) {
            var isSet=workItem.isAttributeSet(WorkItemAttributes.SUMMARY);
             console.log("Get Summary Value Script : isSet : " +isSet);
             var summaryValue=workItem.getValue(WorkItemAttributes.SUMMARY);
             console.log("Get Summary Value : " +summaryValue);
            return summaryValue;
        }
    });
})();


2 other answers

Permanent link

 I just noticed that you are also looking at an alternative to invoke REST service from a script, this should be possible. Have you tried invoking a REST service from a script and have hit any issues with that approach? I would expect it to work like any REST call done via a javascript for example.

0 votes

Comments

Sharoon
I could progress by developing DataConnector plug-in similar to HTTPConnector and it helped me to consume external REST service in a script. It is explained here https://jazz.net/wiki/bin/view/Main/DataSourceValueSetProviders#Tutorial_for_providing_a_custom. Thanks.


Permanent link

Develop data-connector plug-in as explained here https://jazz.net/wiki/bin/view/Main/DataSourceValueSetProviders#Tutorial_for_providing_a_custom and then use the same in Calculated Value Provider Script to integrate with external REST services.

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: Jun 27 '17, 8:18 a.m.

Question was seen: 2,538 times

Last updated: Jul 06 '17, 7:12 a.m.

Confirmation Cancel Confirm