For all stories where the ASCA Required attribute = Yes, the story should not be allowed to move to the Ready For Production state unless the ASCA Certification attribute = Yes.This is the condition for which i should code.
dojo.provide("org.example.workitems.providers.AscaCheck");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); (function() { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; var scriptname = "AscaCheck"; dojo.declare("org.example.workitems.providers.AscaCheck", null, { matches: function(workItem, configuration) { var type = workItem.getValue(WorkItemAttributes.TYPE); var ascareq = workItem.getValue("ierp.ascarequired"); var state = workItem.getValue(WorkItemAttributes.STATE); var ascacert = workItem.getValue("ierp.ascacertification"); if((type == "com.ibm.team.apt.workItemType.story") && (state == "ierp.userstoryworkflow.state.s9") &&(ascareq== "iERPYesNo.literal.l5")) { ascacert = "iERPYesNo.literal.l5"; } return ascacert; } }); })(); can anyone pls check this code and tell me if anything wrong as this is not working for me. Thanks in advance!!! |
Accepted answer
The code is working fine now.By mistake,i kept semicolon after the if statement in the previous code.
dojo.provide("com.example.Validator.AscaCheck"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); dojo.require("com.ibm.team.workitem.api.common.Severity"); dojo.require("com.ibm.team.workitem.api.common.Status"); (function() { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; var Severity = com.ibm.team.workitem.api.common.Severity; var Status = com.ibm.team.workitem.api.common.Status; var scriptname = "AscaCheck"; dojo.declare("com.example.Validator.AscaCheck", null, { validate: function(attributeId, workItem, configuration) { var type = workItem.getValue(WorkItemAttributes.TYPE); var ascareq = workItem.getValue("ierp.ascarequired"); var state = workItem.getValue(WorkItemAttributes.STATE); var ascacert = workItem.getValue("ierp.ascacertification"); if((type == "com.ibm.team.apt.workItemType.story") && (state == "ierp.userstoryworkflow.state.s4") &&(ascareq == "iERPYesNo.literal.l5")) { if(ascacert == "iERPYesNo.literal.l5") { return Status.OK_STATUS; } else { return new Status(Severity["ERROR"], "Yes not selected in ASCA Certification attribute"); } } else{ return Status.OK_STATUS; } console.log("success"); } }); })(); Thanks Anup a lot!!! Ralph Schoon selected this answer as the correct answer
|
2 other answers
Ralph Schoon (63.3k●3●36●46)
| answered Nov 24 '15, 11:28 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Nov 24 '15, 1:51 p.m.
First of all, I would suggest to read Process Enactment Workshop for the Rational solution for Collaborative Lifecycle Management Lab 4 and 5 to understand what conditions do.
When this is out of the way, you understand that a condition itself does nothing. It only works with operational behavior:
Preventing a state change is not on the list.
If you want to do something like that, you need to do it in Java using an Advisor. Here is an example: https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ the code can be enhanced to do what you want.
Comments Or you require an attribute that can not be set in the condition and confuse the heck out of the users.
|
This code looks like something you will use in the calculated value. You should use the validator Attribute customization.
pseudo code given below:
if((type == "com.ibm.team.apt.workItemType.story") && (state == "ierp.userstoryworkflow.state.s9") &&(ascareq== "iERPYesNo.literal.l5"))
{
return Status.OK_STATUS;;
} else{
return new Status(Severity["ERROR"], "Yes not selected in ASCA Certification attribute");
}
Please look at :
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_Based_Validation
Best of Lucks!
Comments Hi Anup,
Hi Venkat,
I number of things can go wrong here although the code looks ok here. Basic things to check:
1) Please make sure attribute Validation Pre-Condition is enabled in your Operation behavior.
2) The validation script is applied to the ASCA Certification attribute.
3) The attribute itself may need to be made dependent to the Status attribute.
4) the attribute ids used are correct. They are case sensitive.
5) use the console log in several different places to see if the code is reachable.
Thats how I debug.
Console.log("Success")
Is this line output visible in the .log file?
6) Make sure scripting itself is enabled in the server.
Hi Anup,
anup Gaur
commented Nov 24 '15, 5:40 a.m.
Make sure attribute Validation is selected. and Save.
",It is showing that no specific configuration options" this is fine. This is how it should be.
Are you able to see the console.log output ?
I am not able to see console.log output.But the code is working fine to some extent.It is not allowing me to go to next state even though i am selecting "yes" for Asca certification attribute.so,where should i configure that value to that attribute?
can we use nested if condition like this-
anup Gaur
commented Nov 24 '15, 10:41 a.m.
You can have as many levels you would like to nest. Looking at the logic :
// test for condition If sate NOT in - Ready For Production - Notice state != condition
if((type == "com.ibm.team.apt.workItemType.story") && (state != "ierp.userstoryworkflow.state.s9"))
{
return Status.OK_STATUS;
}
// test for condition If sate in - Ready For Production and Attribute ASCA has correct value
if((type == "com.ibm.team.apt.workItemType.story") && (state == "ierp.userstoryworkflow.state.s9") &&(ascareq== "iERPYesNo.literal.l5"))
{ return Status.OK_STATUS;
}
else
{
return new Status(Severity["ERROR"], "Yes not selected in ASCA Certification attribute");
}
// The above code can be written in other ways too - This is just a sample
showing 5 of 7
show 2 more comments
|
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.