It's all about the answers!

Ask a question

Can we have populated text of an attribute based on some other value?


Shuchita Tripathi (31436595) | asked Feb 03 '17, 8:43 a.m.
edited Feb 06 '17, 7:47 a.m. by Ralph Schoon (63.5k33646)

Hi,


Can we populate some text in Description field based on the value of an enumeration? For every value of enumeration, the text has to be different.

I tried Default Value and Value Sets from https://jazz.net/wiki/bin/view/Main/AttributeCustomization but I am not getting any success.
I am getting below error:
'Problems loading script com.example.ValueSetProviderDescription
[object Object]
// prepopulate-description.js'

After this, my whole script is mentioned.

RTC v6.0.2

3 answers



permanent link
Dinesh Kumar B (4.1k413) | answered Feb 03 '17, 9:47 a.m.
JAZZ DEVELOPER

Hi Shuchita,

You need a Script Based Calculated Value Script.

Read the Enum Attribute value by using
    workItem.getValue("attributeID")
Set the Description to be dependent on enumeration attribute.

Again you already have access to the best starting point for such customization needs in the article that you mentioned in your question... look for the script based value providers in there...


Comments
Ralph Schoon commented Feb 03 '17, 10:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Also read Process Enactment Workshop for the Rational solution for Collaborative Lifecycle Management Lab 5. It is relatively simple to create a calculated value (and not a valueSet provider.


Ralph Schoon commented Feb 03 '17, 10:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Also Note, that default values can be calculated, but the available information when creating a work item is very small. 


Also note that calculated values and manually editing attributes is a bit of a conflict and usually you would make calculated attributes read only. 


permanent link
Dinesh Kumar B (4.1k413) | answered Feb 03 '17, 8:59 a.m.
JAZZ DEVELOPER

Hi Shuchita,

appears to me that there may be something wrong in the script code... would you mind sharing the script code here... you can obfuscate any important confidential information you have and share the rest...


Comments
Shuchita Tripathi commented Feb 03 '17, 9:15 a.m.

dojo.provide("com.example.ValueSetProviderDescription");

(function() {
  dojo.declare("com.example.ValueSetProviderDescription", null, {
    getValueSet: function(attributeId, workItem, configuration) {
      console.log("My messages");
      var descr = "Some value";
      var attr = "com.ibm.team.workitem.attribute.business"; //ID of attribute Business.(Business is an enum)
      var val_bus = workItem.getValue(attr);
      var hcs-lunar = "com.ibm.team.workitem.enumeration.business.literal.l4"; //ID of value of Business,for which Desc has to be changed
      if (val_bus === hcs-lunar){
        descr = "Changed value";
        return descr; }
      return descr;
      }
});
})();


Shuchita Tripathi commented Feb 03 '17, 9:16 a.m.

 I have never done coding. So please ignore the stupid mistakes. :(


permanent link
Shuchita Tripathi (31436595) | answered Feb 06 '17, 3:41 a.m.
edited Feb 06 '17, 3:42 a.m.
Thank you Dinesh and Ralph for your help!!

The script is working now.

Somehow, I just commented out one line and it started working. 
This is the line which I commented:
var hcs-lunar = "com.ibm.team.workitem.enumeration.business.literal.l4";

I dont understand what was the issue with this line.
Below is the working code.

----------------------------------------------------------------------------------------------------

dojo.provide("com.example.DescriptionValue");

(function() {
    dojo.declare("com.example.DescriptionValue", null, {

        getValue: function(attributeId, workItem, configuration) {
       
            console.log("My messages");
var descrip = "";
var attr = "com.ibm.team.workitem.attribute.business"; // ID of attribute Business. (Business is an enumeration)
var val_bus = workItem.getValue(attr);
//console.log(val_bus);
//var hcs-lunar = "com.ibm.team.workitem.enumeration.business.literal.l4"; //ID of value of Business,for which Desc has to be changed
if (val_bus === "com.ibm.team.workitem.enumeration.business.literal.l4"){
descrip = "Changed Value";
return descrip;
}
return descrip;
        }
   });
})();

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.