How to get value of attribute in Java based calculated value provider plug-in
Hi All,
Accepted answer
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.
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
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.
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.
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.
Comments
Mallanagouda Patil
Jun 28 '17, 12:27 a.m.Here is the sample code am trying