It's all about the answers!

Ask a question

Access value sets from Script Base Calculated Value


Elia Gaglio (2613) | asked Apr 17 '15, 6:30 a.m.
Hi,
i'm developing an extension that uses these objects:

1) a set a value sets with a set of specific values;
2) a Script Base calculated value

When the user select the value for the custom attributes that use value sets, the script base calculated value has been activated. This script should read all the possible value of a specific custom field and return that value.

The code of the script follow:

/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights: 
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
dojo.provide("it.gvb.calculatedValue.readCompetenceCenterIdValues");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
    dojo.declare("it.gvb.calculatedValue.readCompetenceCenterIdValues", null, {

        getValue: function(attribute, workItem, configuration) {
       
        var result = "";
        var competenceCenterId = workItem.getValue("it.gvb.customattribute.competenceCenterId"); // here i should read ALL the values for the custom field that use a value set


var itApplicazioniInterne = "it.gvb.enumeration.competenceCenter.literal.l6";
var dataGovernanceUnit = "it.gvb.enumeration.competenceCenter.literal.l4";

if (competenceCenterId.toLowerCase() == itApplicazioniInterne.toLowerCase()) {
result = "IT-ApplicazioniInterne";
} else
  if (competenceCenterId.toLowerCase() == dataGovernanceUnit.toLowerCase()) {
  result = "DataGovernanceUnit";
  }

console.log("competenceCenterId: " + competenceCenterId);
console.log("result: " + result);

return result;

        }
    });
})();


Any idea? Could someone give more info of how read all values returned from the value set?
Thanks!

One answer



permanent link
Ralph Schoon (63.1k33646) | answered Apr 17 '15, 10:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Apr 17 '15, 10:28 a.m.
As far as I know, you can only access the actual attribute values and not the set of potential values in a calculated value JavaScript. I don't know how you would be able to even find the value set provider for another attribute, if there is one.

There are many limitations in JavaScript attribute calculation, e.g. you can't access the roles of a user, you can't iterate the team area structure and the like. JavaScript is only good for basic customization.

Comments
Jonas Studer commented Apr 20 '15, 3:32 a.m.

Hey Ralph,

Something other than this question.
From where did you get the "Timebox Planning Tool"?

Greetings


Ralph Schoon commented Apr 20 '15, 3:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Guido showed it on an event we had with them and he invited me once they were able to share it.


Ralph Schoon commented Apr 20 '15, 5:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I put links here:  https://rsjazz.wordpress.com/2015/04/13/some-community-extensions-for-rtc/

Your answer


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