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

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

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

0 votes



3 answers

Permanent link

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

1 vote

Comments

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.

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

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

0 votes

Comments

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;
      }
});
})();

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


Permanent link
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;
        }
   });
})();

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: Feb 03 '17, 8:43 a.m.

Question was seen: 2,558 times

Last updated: Feb 06 '17, 7:47 a.m.

Confirmation Cancel Confirm