Making text readonly as read-only on the basis of validation script
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
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
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
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.