It's all about the answers!

Ask a question

Making text readonly as read-only on the basis of validation script


Sajjad Ali Khan (314152) | asked Aug 27 '15, 6:02 a.m.

Dear All,

I need to create a validation script where the scenario is:

1, There is a custom attribute which has YES/No radion buttons

2, There is text field

If user click No on the radio button then the text field will become read-only, following is the script which have created but its not working and giving some errors in a log which is also available below, i have also define it within RTC client > Workitems > Attribute Customization > Validations

Please help me to resolve this issue and achive what i want to achieve

Script:

====

dojo.provide("org.example.workitems.providers.testvalidation");

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.testvalidation" , null, {

matches: function(workItem, configuration){

var rfc = workItem.getValue("arabbank.attribute.rfcisaproject");

console.log(rfc);

if(rfc == "arabbank.enumeration.rfcisproject.literal.l2"){

return ("arabbank.attribute.EPMOReference").readOnly = true;

}

return false;

}

});

})();

Log from the script:

===

!MESSAGE Error invoking validator com.ibm.team.workitem.valueproviders.VALIDATOR._gmqiYEyWEeWLi4nVJprtMQ
!STACK 0
com.ibm.team.repository.common.TeamRepositoryException: Executing Javascript failed.
 at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.handleException(ScriptAttributeValueProvider.java:274)
 at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.validate(ScriptAttributeValueProvider.java:149)
 at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeValidator.validate(AttributeValueProviderRegistry.java:171)
 at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.validate(AttributeImpl.java:930)
 at sun.reflect.GeneratedMethodAccessor109.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
 at java.lang.reflect.Method.invoke(Method.java:619)
 at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)
 at com.sun.proxy.$Proxy43.validate(Unknown Source)
 at com.ibm.team.workitem.client.internal.util.WorkItemEventResolver$InternalBackgroundJob.resolve(WorkItemEventResolver.java:265)
 at com.ibm.team.workitem.client.internal.util.WorkItemEventResolver$InternalBackgroundJob.runProtected(WorkItemEventResolver.java:93)
 at com.ibm.team.foundation.client.util.FoundationJob.run(FoundationJob.java:68)
 at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: com.ibm.team.rtc.common.scriptengine.UnknownFunctionException: 'validate' is not a function
 at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler$MethodHandler$1.run(AbstractInvocationHandler.java:162)
 at com.ibm.team.rtc.common.scriptengine.environment.AbstractScriptEnvironment.execute(AbstractScriptEnvironment.java:74)
 at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler$MethodHandler.invoke(AbstractInvocationHandler.java:156)
 at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler.invokeGeneric(AbstractInvocationHandler.java:141)
 at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:95)
 at com.sun.proxy.$Proxy64.validate(Unknown Source)
 at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.validate(ScriptAttributeValueProvider.java:147)
 ... 11 more

One answer



permanent link
Donald Nong (14.5k614) | answered Aug 28 '15, 3:13 a.m.
edited Aug 28 '15, 3:14 a.m.
The script format is a "condition" script, why do you call it a "validation" script? You have made a condition script in a previous post (with an incorrect conditional testing though), why don't you just follow it as an example?
https://jazz.net/forum/questions/205091/condition-to-make-attribute-mandatory-on-the-basis-of-specific-state-and-specific-option-from-drop-down

In the script above, this line is absolutely incorrect.

return ("arabbank.attribute.EPMOReference").readOnly = true;



Comments
Sajjad Ali Khan commented Aug 28 '15, 3:37 a.m. | edited Aug 30 '15, 9:35 p.m.

 Donald Nong you told me in this post https://jazz.net/forum/questions/204864/how-to-make-read-only-text-field-on-the-basis-of-condition

that you need to create another script for making in read-only in validations script. so i have created as you have said but still i'm not able to achieve what i want achieve.

Kindly me help me out in this case if can guide how to make my script correct or if have that working script for my case

Please help me out.


Donald Nong commented Aug 30 '15, 9:37 p.m.

The "another script" is a condition script, not a validation script. You use a validation script to ensure the attribute is mandatory. You use a condition script to make the attribute read-only.

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.