Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.

0 votes


Accepted answer

Permanent link
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

0 votes


5 other answers

Permanent link
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

0 votes


Permanent link
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

0 votes

Comments

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
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;
    }
});
})();

0 votes

Comments

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.


I even tried with == but no luck

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.

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
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.

0 votes


Permanent link
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;
}
});
})();

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: May 27 '14, 4:47 a.m.

Question was seen: 8,362 times

Last updated: Mar 13 '15, 2:40 a.m.

Confirmation Cancel Confirm