11 views

Description

URL variable validation not working in Service Portal as it does in Desktop UI

Steps to Reproduce

1 - Create a variable type URL in a catalog item
2 - Load the catalog item in Deskop UI and try to submit by entering any text in the variable field
3 - You'll not be able to submit in case it's not a valid URL
4 - Verify in the Service Portal the same does not happen and you can submit the item regardless of the URL field content

Workaround

As a workaround, any validation of a URL field can be done via Catalog Client Script.
 
 
As an example, the following onSubmit catalog client script validates the "URL" variable, preventing the form to be submitted in the URL isn't valid:
 
 
function onSubmit() {
 
var validURL = function (str) {
 try {
    new URL(str);
    return true;
  } catch (_) {
    return false;  
  }
};
   //Type appropriate comment here, and begin script below
   if (!validURL(g_form.getValue('URL'))){
    g_form.addErrorMessage('Please enter a valid URL (Valid URL must begin with a scheme name, e.g. https)');
return false;
   }   
}

Related Problem: PRB1294698

Seen In

Kingston Patch 7

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-09-26 11:44:57
Published:2018-09-20