How do I calculate the summary field based on the custom attribute value in RTC using java script ?
6 answers
Hi Fausto,
Thanks for providing me the link. I have been using the same link to create the script:
I have two attributes :
Component name ( id: component_name)
Component version ( id: component_version)
and I want to combine both in to summary
Here is my Script:
--------------------
dojo.provide("com.example.Calculate_Component_Summary");
(function() {
dojo.declare("com.example.Calculate_Component_Summary", null, {
getValue: function(attribute, workItem, configuration) {
var component = workItem.getValue(component_name);
var version = workItem.getValue(component_version);
var result+= component + " v" + version;
return result;
}
});
})();
am i doing something wrong here ?
Thanks for providing me the link. I have been using the same link to create the script:
I have two attributes :
Component name ( id: component_name)
Component version ( id: component_version)
and I want to combine both in to summary
Here is my Script:
--------------------
dojo.provide("com.example.Calculate_Component_Summary");
(function() {
dojo.declare("com.example.Calculate_Component_Summary", null, {
getValue: function(attribute, workItem, configuration) {
var component = workItem.getValue(component_name);
var version = workItem.getValue(component_version);
var result+= component + " v" + version;
return result;
}
});
})();
am i doing something wrong here ?
when I use the custom attributes i use the below two points
1. use the ID of the attribute and not the name
2. use the ID from within double quotes
for an attribute named Criticality with an ID rcstlt.ms.criticality
the rest of your script looks fine to me.
1. use the ID of the attribute and not the name
2. use the ID from within double quotes
for an attribute named Criticality with an ID rcstlt.ms.criticality
var rCrit = workItem.getValue("rcstlt.ms.criticality");
gets me the valuethe rest of your script looks fine to me.
At https://jazz.net/wiki/bin/view/Main/AttributeCustomization#ScriptBasedNotes
Only values of the following attribute types can be safely read by and returned from scripts:
The summary field type is "Medium HTML" so will not work...
Only values of the following attribute types can be safely read by and returned from scripts:
- Short String
- Medium String
- Large String
- Integer
- Long
- Boolean
- Timestamp as an ISO-8601 standard string. Use
dojo.date.stamp
to convert a JavascriptDate
object to and from an ISO-8601 string. When converting aDate
object to a string set themilliseconds
and thezulu
options to true.- To convert the value of a timestamp attribute with the id
attributeId
to aDate
object use:var date= dojo.date.stamp.fromISOString(workItem.getValue(attributeId));
- To convert a Date object to an ISO-8601 string use:
var string= dojo.date.stamp.toISOString(date, {milliseconds:true, zulu:true});
- To convert the value of a timestamp attribute with the id
- Limited support for Enumeration. See the Working with Enumerations section for more information about using Enumerations in scripts.
- Limited support for Items
The summary field type is "Medium HTML" so will not work...
Your code works for me when i modify the line:
the code
and the component summary is the built-in summary type
component name and version are of small string type
the dependencies
the summary attribute has dependency set on both component version and component name
var result+= component + " v" + version;
tovar result = component + " v" + version;
and use double quoted attribute ids, for reference here is the code which worked for me:the code
dojo.provide("com.example.Calculate_Component_Summary");
(function() {
dojo.declare("com.example.Calculate_Component_Summary", null, {
getValue: function(attribute, workItem, configuration) {
var component = workItem.getValue("component_name");
var version = workItem.getValue("component_version");
var result = component + " v" + version;
return result;
}
});
})();
the attribute types(function() {
dojo.declare("com.example.Calculate_Component_Summary", null, {
getValue: function(attribute, workItem, configuration) {
var component = workItem.getValue("component_name");
var version = workItem.getValue("component_version");
var result = component + " v" + version;
return result;
}
});
})();
and the component summary is the built-in summary type
component name and version are of small string type
the dependencies
the summary attribute has dependency set on both component version and component name