Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Policy on Widget in Service Portal

mattrom1
Giga Expert

I have imported a custom table and widget to use appointment scheduling. It has the ability to show Description field that will be placed on the catalog task once submitted. How do i get the description field to be mandatory on the widget within Service Portal.

 

find_real_file.png

1 ACCEPTED SOLUTION

mattrom1
Giga Expert

I was able to resolve this by using this script

 

			if(c.appntDescription != "") {
			
			
        c.server.get(obj).then(function(response) {
            if (response.data.timeSlotReturn) {
                c.timeSlotReturn = JSON.parse(response.data.timeSlotReturn);
                if (c.timeSlotReturn.sys_id) {
                    c.alertSuccess = true;
                    if (c.setReminder) {
                        c.setupReminder(c.selectedReminderTime.value.display_value);
                    }
                    c.getTimeSlots(selectedDate);
                    c.appntShortDescription = "";
                    c.appntDescription = "";
                    c.appntLocationSysid = "";
                    c.appntLocation = "";
                    $rootScope.$broadcast('appointmentCreated', '');
                }
            }
        });
		
		}	
			else 
			alert ("Please put in a description");
    };

View solution in original post

6 REPLIES 6

Ajaykumar1
Tera Guru

Hi,

You can add a required attribute in your HTML template code.

Example :   Description : <input type="text" name="description" required>

Usage

The required attribute is a boolean attribute.

When present, it specifies that an input field must be filled out before submitting the form.

 

Mark If Correct/Helpful.

Regards,
Ajay
www.DXSherpa.com

mattrom1
Giga Expert

I was able to resolve this by using this script

 

			if(c.appntDescription != "") {
			
			
        c.server.get(obj).then(function(response) {
            if (response.data.timeSlotReturn) {
                c.timeSlotReturn = JSON.parse(response.data.timeSlotReturn);
                if (c.timeSlotReturn.sys_id) {
                    c.alertSuccess = true;
                    if (c.setReminder) {
                        c.setupReminder(c.selectedReminderTime.value.display_value);
                    }
                    c.getTimeSlots(selectedDate);
                    c.appntShortDescription = "";
                    c.appntDescription = "";
                    c.appntLocationSysid = "";
                    c.appntLocation = "";
                    $rootScope.$broadcast('appointmentCreated', '');
                }
            }
        });
		
		}	
			else 
			alert ("Please put in a description");
    };