This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jul 24, 2012, 11:16 PM
47 Posts

Computed Required Validation via SSJS

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 1
I have a select field: preferredContact that has an OTHER option/value.  The client side show/hide when other works to display the OTHER field when preferredContact is changed to / from OTHER.  What I haven't been able to get to work is the check to make sure that if OTHER is selected that the other field contains a value on submit.  Here's the code I am using in the Required field computed value:
 
 
if (getComponent("preferredContact").getValue() == 'Other method'
&& getComponent("other").getValue() == '' ) {
          return true
} else {
          return false
 
I've printed out getComponent("preferredContact").getValue() and .getSubmittedValue() and they both return NULL.  So I'm stumped as to what to do here. Any help is greatly appreciated.
Jul 31, 2012, 5:53 AM
13 Posts
Re: Computed Required Validation via SSJS
Remember that getComponent parameter is case sensisitve. It is good practice to check for null. 
 
I have found the string.methods equals, isEmpty more reliable than just comparison.
 
var pref  =  getComponent("preferredContact").getValue();
var other = getComponent("other").getValue(); 
if ((pref != null)  && (other != null)) { 
  if (pref.equals("Other method") && !other.isEmpty()) {
    return true; 
  } 
return false; 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal