It's all about the answers!

Ask a question

RTC Attribute Customization : Script based Condition not mandating the enumeration field.


Shwetha G (60331) | asked Apr 11 '17, 1:08 a.m.
edited Apr 11 '17, 1:30 a.m. by Ralph Schoon (63.2k33646)

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


Comments
Ralph Schoon commented Apr 11 '17, 1:29 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 Does the script run? Do you see anything in the log files? 


Shwetha G commented 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 ?

3 answers



permanent link
Ralph Schoon (63.2k33646) | answered Apr 11 '17, 3:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 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.


Note, if you change attribute customization close all test work items and open them again to see any behavioral changes. In the Web UI use CTRL+F5 to refresh the browser in addition.


Comments
Shwetha G commented Apr 11 '17, 4:12 a.m.

Thanks for the reply Ralph.

I dont find any issue with the script. :(
What is the problem with the process you mentioned, how can I correct it ?

I tried all  things, and refreshing the browser as well and checked in other browser as well but no luck.

Please assist me on this.


permanent link
Luca Martinucci (1.0k396112) | answered Apr 11 '17, 3:25 a.m.

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
Shwetha G commented Apr 11 '17, 3:34 a.m.

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.







Luca Martinucci commented Apr 11 '17, 3:42 a.m.

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.


Shwetha G commented Apr 11 '17, 3:49 a.m.

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 ?



 


Luca Martinucci commented Apr 11 '17, 4:07 a.m.

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


Shwetha G commented Apr 11 '17, 4:26 a.m.

Luca, Thanks again. I cant select the condition script for the priority attribute,  as it is "Read Only"  field.


Shwetha G commented Apr 11 '17, 4:32 a.m.

i have added the image as well.


Shwetha G commented Apr 11 '17, 6:19 a.m.

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 :)


Luca Martinucci commented Apr 11 '17, 6:30 a.m.

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.

showing 5 of 8 show 3 more comments

permanent link
Shwetha G (60331) | answered Apr 11 '17, 6:17 a.m.

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
Luca Martinucci commented Apr 11 '17, 6:28 a.m.

When an attribute is mandatory, and its value is "Unassigned", the work item save fails, so you have to select a different value.
Actually the Unassigned Literal is the literal that "tells" RTC that the attribute has not a "real" value associated.

Your answer


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