Can you make a field required through script in Service Catalog form?
search cancel

Can you make a field required through script in Service Catalog form?

book

Article ID: 244120

calendar_today

Updated On:

Products

CA Service Catalog

Issue/Introduction

Can you make a field required through script in Service Catalog form?  I know the normal way to make a field required is on the form but if a field needs to be conditionally required can you make it required using a script?

Environment

Release : 17.3

Component : Catalog - Request Creation

Resolution

You would need to create a function to validate that the field is not empty. If it's empty, then you can show an alert and return false and it won't allow you to continue. If it's not empty, you can call another function, return true and continue with the ticket creation.

Here is an example :

    if(ca_fdIsSelectRadio(formId, "fieldname", "No")){
            if (user == "");
        alert("Requested For cannot be blank");
         return false;
      
    } else {
      alert('else no');
         return true;
    }
    if(ca_fdIsSelectRadio(formId, "fieldname", "Yes")){
            if (auserid == "");
         return false;
    } else {
      alert('else yes');
      return true;
    }
    }