- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 08:52 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2018 11:00 AM
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");
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 08:56 AM
Hi,
You need to edit the widget to make that field mandatory.
If you could add widget code, we can give more specific answer here.
Cheers,
Sunil B N

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 09:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 10:41 AM
I have tried the link above but it is not working, here is the client script (I removed the information from the link provided)
function scheduleAppointment($rootScope, $timeout, $http, $scope) {
var c = this;
c.$onInit = function() {
c.selectedSlot = "";
c.timeSlotReturn = "";
c.alertSuccess = false;
c.setReminder = false;
c.appntShortDescription = "";
c.appntDescription = "";
c.appntLocationSysid = "";
c.selectedReminderTime = c.data.reminderTimes[0];
}
c.getTimeSlots = function(date) {
c.dateFormatted = moment(date).format("dddd, MMMM D YYYY");
c.server.get({ action: 'getTimeSlots', selectedDate: moment(date).format("YYYY-MM-DD") }).then(function(response) {
if (response.data.timeSlots && response.data.timeSlots.length > 0) {
c.timeSLots = JSON.parse(response.data.timeSlots);
if (c.options.layout == 'Dropdown') { c.selectedSlot = c.timeSLots[0]; }
}
});
};
c.locationChosen = function(location) {
c.appntLocation = location;
c.appntLocationSysid = location.sys_id;
}
c.getLocations = function(val) {
return $http.get('/api/now/table/cmn_location?sysparm_query=nameLIKE' + val + '^ORstreetLIKE' + val + '^ORcityLIKE' + val + '^ORstateLIKE' + val + '&sysparm_limit=5', {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-UserToken': window.g_ck
}
}).then(function(response) {
return response.data.result;
});
};
c.setupReminder = function(reminderTime) {
c.server.get({ action: 'setupReminder', selectedTime: reminderTime, taskSysid: c.timeSlotReturn.sys_id }).then(function(response) {
c.reminderSetup = response.data.reminderReturn;
$timeout(function() {
c.alertSuccess = false;
c.setReminder = false;
}, 5000);
});
}
function processTheTimes(appointments) {
for (var i = 0; i < appointments.length; i++) {
appointments[i].work_start = moment(appointments[i].work_start).fromNow();
if (appointments[i].duration > 0) {
appointments[i].duration = Math.floor(appointments[i].duration / 60);
}
}
return appointments;
}
c.datePickerPopup = {
opened: false
};
var today = new Date();
if (!c.options.max_date) {
c.options.max_date = 30;
}
c.dateOptions = {
showWeeks: false,
formatYear: 'yyyy',
maxDate: today.setDate(today.getDate() + parseInt(c.options.max_date)),
minDate: populateDate(),
startingDay: 1
};
// Disable weekend selection
c.disabled = function(date, mode) {
return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
}
c.openDatePickerPopup = function() {
c.datePickerPopup.opened = true;
};
c.submitTimeSlot = function(selectedDate, selectedSlot) {
var obj = {
'action': 'setTimeSlots',
'meetingDate': selectedDate,
'meetingTime': selectedSlot
}
if (c.appntLocation || c.appntDescription || c.appntShortDescription) {
obj.additionalFields = {
'short_description': c.appntShortDescription,
'description': c.appntDescription,
'location': c.appntLocationSysid
}
}
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', '');
}
}
});
};
function populateDate() {
c.minDate = new Date();
c.getTimeSlots(c.minDate);
c.selectedDate = c.minDate;
c.dateFormatted = moment(c.selectedDate).format("dddd, MMMM D YYYY");
return c.minDate;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2018 09:23 PM
You can add check in submitTimeSlot to check if there is short description or not before calling c.server.get(obj) or in HTML code you can add mandatory="true" for input element.
Cheers,
Sunil B N