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

How to make read-only text field on the basis of condition

 Hi All, 

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

0 votes


Accepted answer

Permanent link
You cannot do this in a validation script. You need to use a condition script to make it "dynamic read-only". See the "Dynamic read-only attributes with conditions" section in the below article for details.
https://jazz.net/library/article/997#dyncondition
Ralph Schoon selected this answer as the correct answer

0 votes

Comments

  Donald Nong yes you are right i'm not creating validation for above scenario, that why i have create a condition, could you please just incorporate Read-only part in above provided script ???


i hope you ave understand the issue which i have written above and my script is also working fine but i just need to incorporate read-only part within the same script.

It appears that you did not completely understand what I meant. Let me put it this way, you will need two (not just one) scripts to achieve what you want - a "validation" script to make sure the attribute is mandatory, and a "condition" script to make sure the attribute is read-only. You cannot mix them together.

 Donald Nong Thanks brother for the clarification but how can i create the second script which will be used as condition for read-only part, could you please help me 

An example was already given in my original answer.

See the "Dynamic read-only attributes with conditions" section in the below article for details.
https://jazz.net/library/article/997#dyncondition

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
× 12,020
× 7,495
× 457

Question asked: Aug 19 '15, 4:09 a.m.

Question was seen: 4,164 times

Last updated: Aug 24 '15, 8:10 p.m.

Confirmation Cancel Confirm