RTC Attribute Customization : Script based Condition not mandating the enumeration field.
Hello All,
I need to have a script based condition where the Priority should become mandate when the severity is "Critical and blocker".
I am able to get the asterisk mark for the priority, when i select the severity as Critical, But when i save the workitem am not getting any error messages saying "Attribute "Priority" not set".
Why conditions are not working for enum values ?
Following is the code :
dojo.provide("example.Condition");
(function() {
dojo.declare("example.Condition", null, {
matches: function(workItem, configuration) {
var workitem = com.ibm.team.workitem.api.common.WorkItemAttributes;
var severity = workItem.getValue(workitem.SEVERITY);
var priority = workItem.getValue(workitem.PRIORITY);
if((severity == "severity.literal.l5" || severity == "severity.literal.l6") && (priority == "priority.literal.l1")
return true;
else
return false;
}
});
})();
Also i have configured this script in pre-condition.
Request you to assist on this.
Regards,
Shwetha
3 answers
I have successfully used conditions with making enumeration attributes mandatory. So it is likely an issue with the JavaScript or a weird problem with your process which would require support to look at it.
Shwetha,
looking at yout script, it seems that it returns true only in one particular case:
- the severity is either l5 or l6
- and
- the priority is l1
In all other cases, it returns false
That means that any attribute associated with this script will not be mandatory in all other cases; so, if the priority is not l1, it will not be mandatory.
Is this really the behavior you want to implement?
If your goal is set the Priority mandatory according to the value of the Severity, why do you put the value of the Priority in the "if" condition?
Comments
Hi Luca,
Thanks for your reply. priority l1 is unassigned.
So am checking if the severity is "Crictical or blocker" and Priority is "Unassigned" then return true.
Am getting the asterisk, mean the script is fine....but on Save error message is not displayed.and not blocking the user to save.
Request you to assist on this.
Shwetha,
remove the (priority == "priority.literal.l1") from the if statement.
Then, enable this script-based condition for the Priority attribute.
Also, remember to activate the "Required attribute for condition" precondition in the process customization.
Luca, thanks for your quick response.
I tried removing the priority form the script. Also in the beginning only i have configured the pre-condition "Required attribute for condition" and selected the priority attribute in the pop -up.
I didnt understand this : Then, enable this script-based condition for the Priority attribute.
What are the steps for doing this ?
Shwetha,
select the Priority attribute and click Edit: the properties window of the attribute will be displayed.
Then, select your script-based condition from the Conditions drop-down list.
And also, remember to add the Severity to the list of Dependencies (in the same properties window).
Luca, Thanks again. I cant select the condition script for the priority attribute, as it is "Read Only" field.
i have added the image as well.
Luca, I think the condition is always disabled, as i mentioned. Script based conditions should only be configured in pre-conditions. But the issue was different as mentioned below and i fixed it :)
I am happy that you solved the issue.
I remembered (wrongly) that the script-based conditions had to be enabled on each attribute for which that had been developed.
Actually, in your case, the problem was different.
Hello Ralph and Luca,
I found where the issue was :)
I tired the same script for other enumeration value, it worked fine....
Then i checked the enumeration of the "Priority"..there the "Unassigned Literal" value was "None", for other enumerations, the value was "Unassigned".
When i set this value to the priority, it worked :)
What is the need for setting this "Unassigned Literal" value ?
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Apr 11 '17, 1:29 a.m.Does the script run? Do you see anything in the log files?
Shwetha G
Apr 11 '17, 1:35 a.m.Thanks for the reply Ralph.
I am printing severity and priority values and am getting the values. other than that am not getting any issues.
When i change the mandatory field from priority to any other integer value...i get the asterisk mark and also the error message "Attribute " some test" not set".
why is this like this ?