Making Attribute as a mandatory using workitems action in RTC
We are now using Rational Team Concert 4.0.1 version (Windows Platform). we want to make one field (Attribute) as a mandatory field based on action name (while selecting action in workitem).
So please let me know the function OR code details for making the attribute as mandatory.
Note: We can make fields as mandatory based on state name using “Required Attributes” precondition in operation behavior but we want to make some mandatory fields based on action name.
Accepted answer
Hello,
Now the same script is working fine in my environment. I found 2 issues and resolved them.
1. There was an empty script which was showing errors in the console log. I removed it from Links.
2. Old script was picked from links because i was using the same name for .js file.
When I resolved above issues, script is working perfectly fine. The attribute is turned on as mandatory attribute and work item is not saved, if the attribute is empty.
Thanks for the links and help.
Now the same script is working fine in my environment. I found 2 issues and resolved them.
1. There was an empty script which was showing errors in the console log. I removed it from Links.
2. Old script was picked from links because i was using the same name for .js file.
When I resolved above issues, script is working perfectly fine. The attribute is turned on as mandatory attribute and work item is not saved, if the attribute is empty.
Thanks for the links and help.
5 other answers
Please see: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript
Use:
with the
Required Attributes For Condition
Precondition/Advisor
Use:
since 4.0 M1getWorkflowAction()returns a string that is the id of a workflow action currently selected by the user. This action will be executed when the item is saved. If the user has not selected any action this method will returnnull. Note: This method works only when used inside a Condition script, the return value will always benullwhen this is used in other customization script types.
with the
Required Attributes For Condition
Precondition/Advisor
Dear Ralph,
Thanks for your support!!.
As mentioned, I have created below dojo script to make a attribute as mandatory based on action but it is not working. Could you please help on this?.
FYI,
dojo.provide("SQLQualityStatus");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes
dojo.require("com.ibm.team.workitem.api.common.Status"); // To create a status object to return
(function() {
dojo.declare("SQLQualityStatus", null, {
getValue: function(attribute, workItem, configuration) {
var SQLQuality = getWorkflowAction();
if(SQLQuality === "ChangeRequestWorkFlow.action.a113") { // ChangeRequestWorkFlow.action.a113 == action ID
return true;
}
return false;
}
});
})();
Thanks,
Rajiv
Thanks for your support!!.
As mentioned, I have created below dojo script to make a attribute as mandatory based on action but it is not working. Could you please help on this?.
FYI,
dojo.provide("SQLQualityStatus");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes
dojo.require("com.ibm.team.workitem.api.common.Status"); // To create a status object to return
(function() {
dojo.declare("SQLQualityStatus", null, {
getValue: function(attribute, workItem, configuration) {
var SQLQuality = getWorkflowAction();
if(SQLQuality === "ChangeRequestWorkFlow.action.a113") { // ChangeRequestWorkFlow.action.a113 == action ID
return true;
}
return false;
}
});
})();
Thanks,
Rajiv
I have the same requirement, to make an attribute mandatory based on the workflow action. Here is the code, which is NOT working. Could you please help.
dojo.provide("com.ibm.team.workitem.rejectbydesign");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.ibm.team.workitem.rejectbydesign", null, {
getValue: function(attributeId, workItem, configuration) {
var action= configuration.getWorkflowAction();
if ( action === "projectstatustracking.action.a30" ) {
// action is reject by design
return true;
}
return false;
}
});
})();
dojo.provide("com.ibm.team.workitem.rejectbydesign");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.ibm.team.workitem.rejectbydesign", null, {
getValue: function(attributeId, workItem, configuration) {
var action= configuration.getWorkflowAction();
if ( action === "projectstatustracking.action.a30" ) {
// action is reject by design
return true;
}
return false;
}
});
})();
Comments
Yes. I enabled the pre-condition in operation behavior.
I am using RTC Version 5.0.1 and the pre-condition enabled is "Required Attributes for Condition"
Using the console log, I see that as soon as I click on save on the work item, the getWorkflowAction() is changed and the attribute becomes non-mandatory.
I am using RTC Version 5.0.1 and the pre-condition enabled is "Required Attributes for Condition"
Using the console log, I see that as soon as I click on save on the work item, the getWorkflowAction() is changed and the attribute becomes non-mandatory.
The script is working fine for 4.0.6.
Is there any issue in 5.0.1?
Here is the script
dojo.provide("com.ibm.team.workitem.rejectbydesign");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.ibm.team.workitem.rejectbydesign", null, {
// getValue: function(attributeId, workItem, configuration) {
matches: function(workItem, configuration) {
var act= configuration.getWorkflowAction();
console.log(" action is = " +act);
if (act === "projectstatustracking.action.a30" ) {
// action is reject by design
console.log(" action is reject by design---true");
return true;
}
console.log(" action is reject by design----false");
return false;
}
});
})();
Is there any issue in 5.0.1?
Here is the script
dojo.provide("com.ibm.team.workitem.rejectbydesign");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.ibm.team.workitem.rejectbydesign", null, {
// getValue: function(attributeId, workItem, configuration) {
matches: function(workItem, configuration) {
var act= configuration.getWorkflowAction();
console.log(" action is = " +act);
if (act === "projectstatustracking.action.a30" ) {
// action is reject by design
console.log(" action is reject by design---true");
return true;
}
console.log(" action is reject by design----false");
return false;
}
});
})();