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. Ralph Schoon selected this answer as the correct answer
|
5 other answers
![]()
Ralph Schoon (62.0k●3●36●43)
| answered May 27 '14, 5:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please see: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript
Use: since 4.0 M1 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 Comments ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I would suggest to carefully read the https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript again to figure out where to get the workflow action. It is a method on the configuration data.
|
![]()
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; } }); })(); Comments ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Debug your script. See https://jazz.net/library/article/1360
I even tried with == but no luck
Hello Ralph,
Did you configure the operation behavior (pre-condition) that is mentioned in https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Conditions and the Enactment Workshop?
|
![]()
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. |
![]()
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; } }); })(); |