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!!!
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!!!
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!!!
2 other answers
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
showing 5 of 7
show 2 more comments
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:
- Required for condition
- Read Only for condition
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.