It's all about the answers!

Ask a question

Making Attribute as a mandatory using workitems action in RTC


Rajiv Gandhi (34712) | asked May 27 '14, 4:47 a.m.

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


permanent link
Anitha Nalluri (311010) | answered Mar 13 '15, 2:40 a.m.
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



permanent link
Ralph Schoon (63.1k33645) | 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 getWorkflowAction() 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 return null . Note: This method works only when used inside a Condition script, the return value will always be null when this is used in other customization script types.

with the

Required Attributes For Condition

Precondition/Advisor

permanent link
Rajiv Gandhi (34712) | answered May 28 '14, 9:50 a.m.
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
Ralph Schoon commented May 28 '14, 10:20 a.m.
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.


permanent link
Anitha Nalluri (311010) | answered Mar 02 '15, 3:58 a.m.
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
Ralph Schoon commented Mar 02 '15, 4:08 a.m. | edited Mar 02 '15, 4:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Debug your script. See https://jazz.net/library/article/1360
You can also print to the logs. See https://jazz.net/library/article/1093 Lab 5
Not sure if === as opposed to == could be a problem.



Anitha Nalluri commented Mar 02 '15, 4:22 a.m.

I even tried with == but no luck


Anitha Nalluri commented Mar 05 '15, 4:54 a.m.

Hello Ralph,

Thanks for the links. I debugged my script using above article.
I found an error in the condition script. I rectified it.
Now, it shows a mandatory field sign for the attribute, if the given workflow is selected. But after that, even if that mandatory field is null, it saves the WI. It does not give any error and moves to next state.


Ralph Schoon commented Mar 05 '15, 5:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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?


permanent link
Anitha Nalluri (311010) | answered Mar 05 '15, 5:28 a.m.
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.

permanent link
Anitha Nalluri (311010) | answered Mar 06 '15, 3:26 a.m.
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;
}
});
})();

Your answer


Register or to post 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.