Can someone please tell me why Catalog UI Policy and/or Catalog Client Script is working in Service Catalog but not in Employee Portal?

Hola Ola
Giga Guru

Hello, 

I have a Catalog item date field with (attached) Catalog UI Policy and/or Catalog Client Script is working fine in Service Catalog but not in Employee Portal?

In the Date Field, user will not be able to select any day that is less than 10 days from the current date;

Catalog Client Script:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var ga = new GlideAjax('ValidateBusinessDays');
    ga.addParam('sysparm_name', 'bdaysAgoStart');
    ga.addParam('sysparm_day', "10");
    ga.addParam('sysparm_newDate', newValue);
    ga.getXML(validateDate);
}

function validateDate(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    if(answer=="error")
        {
            alert("Please select a date that is at least 10 business days from today");
            g_form.setValue("what_is_the_requested_date_of_completion","");
        }

}

find_real_file.png

Catalog UI Policy:
find_real_file.png

________________

find_real_file.png

Again, this works perfectly well in Service Catalog (ITIL) view - I'm not able to submit the form without adhering to the 10-day requirement.

BUT

Even though the message appears in Employee Portal, a User is still able to submit the form without meeting the 10-day requirement.

Is there a line of code or setup I am missing?

 

Thank you.

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

Make type as All. Also, I hope your variable is mandatory. if so, just add below line after error message line:

g_form.setValue("preferred_due_date_of_the_request", " ");
Regards,
Muhammad

View solution in original post

2 REPLIES 2

MrMuhammad
Giga Sage

Make type as All. Also, I hope your variable is mandatory. if so, just add below line after error message line:

g_form.setValue("preferred_due_date_of_the_request", " ");
Regards,
Muhammad

Mohith Devatte
Tera Sage
Tera Sage

Hello @Hola Ola ,

in the Run script of the UI policy please change the "run scripts in UI type" field to "ALL" which runs in service portal and the catalog item view too