Read-only attribute for condition is preventing save work item
I am using RTC 4.0.1. I have created a script-based condition and configured precondition "Read-only attribute for condition" for a specific role.
When I want to save a work item, even if my javascript is always returning false, I always get an error that says the attribute is not modifiable (this attribute is selected as the read-only attribute).
Here is the content of my original script:
dojo.provide("com.test.Condition.assignedManagerMatch");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;dojo.declare("com.test.Condition.assignedManagerMatch", null, {
matches: function(workItem, configuration) {
var owner = workItem.getValue(WorkItemAttributes.OWNER);
var modifiedby = workItem.getValue(WorkItemAttributes.MODIFIED_BY);
if (owner != modifiedby) {
return true;
}
return false;
});
})();
At this point, I am not sure if there is a problem with my javascript or there is a bug in the precondition.
Is anyone else experiencing the same problem?
Accepted answer
The "Read-only attribute for condition" precondition verifies that work items match the condition selected in the configuration. A sample 'Condition' script is as below. Could you try a simple version below and see if it works? If it works, I would try to print out the value of owner and modifiedby to compare.
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
dojo.provide("com.example.Condition");
(function() {
dojo.declare("com.example.Condition", null, {
matches: function(workItem, configuration) {
return true;
}
});
})();
/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
dojo.provide("com.example.Condition");
(function() {
dojo.declare("com.example.Condition", null, {
matches: function(workItem, configuration) {
return true;
}
});
})();
4 other answers
Hi Alicia,
I would check if you did not select the attribute read only somewhere else. I would also chack https://jazz.net/library/article/1093 Lab 5 for hints about debugging or at least using the log. That lab is also a good resource to learn.
I would dump the user ID's you are getting and also check JavaScript as there is an === available as well.
Make sure to upload your latest condition script as well. If you do so, you must close the work item and open it again to get your editor recognize the new script version. And as suggested by Piotr, I would first return a false without any other processing and make sure it works.
As an after thought check the Logs, it is not CCM.log you have to look at, The workshop Lab 5 mentioned above explains where to find the log you are looking for. In your case it is most likely the server version.
I would check if you did not select the attribute read only somewhere else. I would also chack https://jazz.net/library/article/1093 Lab 5 for hints about debugging or at least using the log. That lab is also a good resource to learn.
I would dump the user ID's you are getting and also check JavaScript as there is an === available as well.
Make sure to upload your latest condition script as well. If you do so, you must close the work item and open it again to get your editor recognize the new script version. And as suggested by Piotr, I would first return a false without any other processing and make sure it works.
As an after thought check the Logs, it is not CCM.log you have to look at, The workshop Lab 5 mentioned above explains where to find the log you are looking for. In your case it is most likely the server version.
Comments
1 vote
Alicia,
this is a condition that I did recently and it worked for me.
this is a condition that I did recently and it worked for me.
/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* CorrectedEstimateSetCondition
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
dojo.provide("com.acme.providers.script.CorrectedEstimateSetCondition.js");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var doDebug = true;
var scriptname = "CorrectedEstimateSetCondition.js";
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.acme.providers.script.CorrectedEstimateSetCondition.js", null, {
matches: function(workItem, configuration) {
debug("Start");
var correctedEstimate = workItem.getValue("com.acme.wi.attrib.incident.correctedeffort");
debug("correctedEstimate: " + correctedEstimate);
if(correctedEstimate==""){
return false; // Nothing to do
}
debug(" Required");
return true;
function debug(display){
if(doDebug){
console.log(scriptname + " " + display);
}
}
}
});
})();
Comments
Hi All,
I have similar kind of problem but i'm not able to resolve it, i have a attribute which has two radio button "Yes" & "No" and the text field.
Validation which i need to implement is if user click on "Yes" then text field become mandatory and if user click "No" then text field become read-only.
My script works fine if user click YES then text field become mandatory but if user click NO then text field doesn't become read-only.
Please help me to implement read-only part in following script:
dojo.provide("org.example.workitems.providers.RFCandEPMOReference1");
dojo.provide("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.RFCandEPMOReference1" , null, {
matches: function(workItem, configuration){
var rfc = workItem.getValue("ThisRFCisProject.attribute");
console.log(rfc);
if(rfc == "enumeration.ThisRFCisProject.literal.l4"){
return true;
}
return false;
}
});
})();
Comments
Piotr Aniola
Apr 17 '13, 5:19 a.m.Milan Krivic
Aug 18 '15, 5:48 p.m.Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Apr 17 '13, 10:32 a.m.Antonio Gracia
Jan 14 '16, 11:02 p.m.