It's all about the answers!

Ask a question

Help with Script Create - Set the Value for Enumerations


Matt Muller (58312462) | asked Jul 15 '14, 7:03 a.m.
 Hi,

I need some help to create a script which will populate an Enumeration when a work item is created:

So I have an Enumeration:  Enum1
Values:  1 Initial;  2 Study

I have then created two Attributes in the work items:
Milestone1
Milestone2

What I would like is to automatically set:
  • Milestone1 Enumeration to "1 Initial"
  • Milestone2 Enumeration to "2 Study"
 So I need a script which populates these Enumeration values.
Any help would be great.

Thanks

One answer



permanent link
Ralph Schoon (61.2k33643) | answered Jul 15 '14, 7:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 15 '14, 7:42 a.m.
Please see https://jazz.net/library/article/1093 lab 5. You need to create two default value provider scripts and return the enumeration literal ID's.

Comments
Matt Muller commented Jul 21 '14, 8:28 a.m.

 Hi is it not possible to have one script that defines all Variables:


If possible could you provide an example?


Ralph Schoon commented Jul 21 '14, 8:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

A value provider can only provide the value to one attribute. You can use the same provider for several ones if the type matches.

Here is example code - consider to read the workshop.

/***********
 * 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("com.ibm.js.rtc.wi.provider.default.Skeleton");

(function() { dojo.declare("com.ibm.js.rtc.wi.provider.default.Skeleton", null, {

getDefaultValue: function(attribute, workItem, configuration) {

    //var value = //... //Some code that computes a return value
    //return value;
    return "priority.literal.l3" // Medium priority
}

}); })();


Matt Muller commented Jul 21 '14, 9:22 a.m.

 I've found this script as I'm new and do not understand scripting: how can this be expanded for all mappings?

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

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

    getDefaultValue: function(attribute, workItem, configuration) {

        return "Risk.literal.l3"

    }
});

})();


Ralph Schoon commented Jul 21 '14, 9:25 a.m. | edited Jul 21 '14, 9:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Start here: https://jazz.net/wiki/bin/view/Main/AttributeCustomization and https://jazz.net/library/article/1093 lab 5

You can only deal with one enumeration at a time.
If you use the same enumeration for all attributes, you could use the attribute ID 'attribute' from the call.
e.g. if(attribute="id.of.attrib1") ....


Matt Muller commented Jul 21 '14, 12:04 p.m.

Hi,

I'm using the same enumeration;  so how would you add the script for that?
sorry to ask simple question - but can you provide an example in the script above


Ralph Schoon commented Jul 22 '14, 2:17 a.m. | edited Jul 22 '14, 2:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If you would just care to look at the workshop and the other link I proposed you to read, all your questions would be answered, I think.

showing 5 of 6 show 1 more comments

Your answer


Register or to post your answer.