get all initial values of choice field in a record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
There is a choice field in a Record Producer that has values from 10:00 AM thru 5:00 PM with each hour having 4 entries in 15 minute intervals (i.e. 10:00 AM, 10:15 AM, 10:30 AM & 10:45 AM & so on).
I want these values to compare against an application that may already have some records with those times.
If an application record has 10:15 AM then the choice field in the Record Producer needs to show that entry as unavailable choice.
The script pulls the entries from the application but the .getControl or .getOptions or other attempts to retrieve the initial choice field values fail to be programmatically retrieved to do any compare between the Record Producer and the applications records that were retrieved.
function onLoad() {
//Query for all times already allotted on the Date specified.
var pdate = g_form.getValue('photoshoot_date');
console.log('pdate: ' + pdate);
var ga = new GlideAjax('PhotoshootSlotChecker');
ga.addParam('sysparm_name', 'getUnavailableSlots');
ga.addParam('sysparm_date', pdate);
//
ga.getXMLAnswer(function(response) {
var unavailable = response.split(',');
var timeSlotField = g_form.getControl('time_slot');
console.log('timeSlotField.options.length: ' + timeSlotField.options[1] + '\nunavailable: ' + unavailable);
for (var i = 0; i < timeSlotField.option.length; i++) {
var option = timeSlotField.options[i];
console.log('unavailable: ' + unavailable + " option.value: " + option.value);
if (unavailable.includes(option.value)) {
option.disabled = true;
option.text += ' (Unavailable)';
}
}
});
}
