Calculated value script to check if a contributor list has 'no value' or one one or more names assigned.
Hope someone can assist with issue when creating a new calculated value script, I want to check whether a Contributor List has 'No values' or one or more names assigned. I do not need to retrieve the assigned values if there are any, merely a Boolean check if the list is 'empty'.
I have an attribute:
Name Type ID Whom in the Dev Centre has signed off the scope and user stories (or would sign off the stable draft)? Contributor List DevCentreSignOffofRSD In the following JavaScript for a calculated value Dev Centre Requirements Sign Off RAG, I want to check if this list is empty. dojo.provide("DCReqSigOff"); (function() { dojo.declare("DCReqSigOff", null, { getValue: function(attribute, workItem, configuration) { var RSDSigOffByDC = workItem.getValue("RSDSignedOffbyDevCentre"); var StaDraRSD = workItem.getValue("StableDraftRSD"); var RSDSigOffBy = workItem.getValue("DevCentreSignOffofRSD"); if (RSDSigOffByDC == true && RSDSigOffBy !== null) return "CriteriaOutcome.literal.l2"; else if (StaDraRSD == true && RSDSigOffBy !== null) return "CriteriaOutcome.literal.l3"; else return "CriteriaOutcome.literal.l4"; } }); })(); I have tried various options for the variable RSDSigOffBy using getValue and getLabel, and checking for a null, empty string or "No value" without success. |
Accepted answer
Ralph Schoon (63.3k●3●36●46)
| answered May 23 '16, 7:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I have not tried to test reading list type attributes. Not sure if that is even supported.
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript says the below and does not even list list type variables and I have to assume it does not support it. The Java API would support this however.
Currently there is no dedicated API to work with Items or Enumerations and scripts can only use the id of such attributes. If you need additional information, such as the name that corresponds to an Enumeration literal id, you can pass it to scripts using configuration parameters. See the Configuring additional script parameters section for more information. g k selected this answer as the correct answer
|
2 other answers
Ralph Schoon (63.3k●3●36●46)
| answered May 23 '16, 6:57 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
In your "Requirement" you have an ID: DevCentreSignOffofRSD
In your Script you use var RSDSigOffByDC = workItem.getValue("RSDSignedOffbyDevCentre"); which is a different ID. A contributor List should return something list like and RSDSigOffByDC == true does not make sense. |
Hi Ralph, The attribute RSDSignedOffbyDevCentre is actually a Boolean, so RSDSigOffByDC == true is correct. The attribute in question is DevCentreSignOffofRSD , defined in the third var as RSDSigOffBy . The above script tests the list with RSDSigOffBy !== null . We have tried varies other checks, including (but not limited to): RSDSigOffBy.length !== 0 RSDSigOffBy.isEmpty()
|
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.