
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2016 11:58 AM
I have a service catalog item that, based on xyz, will pull up a UI Page, in which I've perfectly matched the fields.
The following code works GREAT! with all fields except for those fields that are drop-downs (select box), that has a value of --None--
var items = document.getElementsByTagName('item');
var myField = '';
var myFieldID = '';
var field;
for (var i = 0; i < items.length; i++)
{
// Clear out all fields
myField = items[i].id;
myFieldID = '';
if (myField.length > 0)
{
myFieldID = ("IO:" + myField);
}
if (myFieldID.length > 0)
{
field = gel(myFieldID);
}
if (field)
{
field.value = '';
variableOnChange('IO:' + myField);
}
}
It clears out all the data, but will not put those darn slect boxes back to --None--
Any ideas?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2016 06:33 AM
I figured it out... and it's my fault. It was my code. Setting field.value = '' does indeed work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2016 03:48 AM
I'm manipulating that control (along with all the other fields) from within a UI Page. Everything works except for this select box, and it's because it has the Include none feature.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2016 05:30 AM
I'm not sure if it'll help or not to show my UI Page code, but here goes:
XML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_userLoc" value="${gs.getUser().getLocation()}" />
<j:set var="jvar_userID" value="${gs.getUserID()}" />
<script>
addLateLoadEvent(function(){
parseArray('${jvar_userID}');
});
</script>
<div align="center">
<table>
<tr><td colspan="3"><button onclick="parseArray('${jvar_userID}')" />test</td></tr>
<tr>
<td id="selectSAVEDrecord"></td>
<td style="width:25px;"></td>
<td id="selectRITMrecord"></td>
</tr>
</table>
</div>
</j:jelly>
Client Script:
function parseArray(userID)
{
var gaj = new GlideAjax('access_claims_info_check_1');
gaj.addParam('sysparm_name','access_claims_info_check_1');
gaj.addParam('sysparm_userID', userID);
gaj.addParam('sysparm_comingFrom', 'uipage');
gaj.getXMLWait();
var answer = gaj.getAnswer();
var answerArray = answer.evalJSON();
var sysID_RITM = "";
var sysID_SAVED = "";
var selectArray_RITM = [];
var selectArray_SAVED = [];
var RITM_records = [];
var SAVED_records = [];
if (answerArray.length > 0)
{
for (var i = 0; i < answerArray.length; i++)
{
if (answerArray[i]['RITM'].length > 5)
{
RITM_records.push(answerArray[i]);
sysID_RITM = answerArray[i]['recordSysID'];
selectArray_RITM.push({recordSysID: sysID_RITM, Display: answerArray[i]['RITM'] });
}
else
{
SAVED_records.push(answerArray[i]);
sysID_SAVED = answerArray[i]['recordSysID'];
selectArray_SAVED.push({recordSysID: sysID_SAVED, Display: answerArray[i]['ATLI'] });
}
}
}
// Is there an RITM array?
if (selectArray_RITM.length > 0)
{
var selEl_RITM = gel('selectRITMrecord');
if (selEl_RITM)
{
var txt_RITM = '<label for="selectRITM">Choose rejected record</label><select id="selectRITM"><option selected="SELECTED">--Choose--</option>';
for (var i = 0; i < selectArray_RITM.length; i++)
{
txt_RITM += '<option value="';
txt_RITM += selectArray_RITM[i]['recordSysID'];
txt_RITM += '">';
txt_RITM += selectArray_RITM[i]['Display'];
txt_RITM += '</option>';
}
txt_RITM += '</select>';
selEl_RITM.innerHTML = txt_RITM;
}
}
// Is there an SAVED array?
if (selectArray_SAVED.length > 0)
{
var selEl_SAVED = gel('selectSAVEDrecord');
if (selEl_SAVED)
{
var txt_SAVED = '<label for="selectSAVED">Choose saved record</label><select id="selectSAVED"><option selected="SELECTED">--Choose--</option>';
for (var i = 0; i < selectArray_SAVED.length; i++)
{
txt_SAVED += '<option value="';
txt_SAVED += selectArray_SAVED[i]['recordSysID'];
txt_SAVED += '">';
txt_SAVED += selectArray_SAVED[i]['Display'];
txt_SAVED += '</option>';
}
txt_SAVED += '</select>';
selEl_SAVED.innerHTML = txt_SAVED;
}
}
doThis(RITM_records, SAVED_records);
}
function doThis(RITM_records, SAVED_records)
{
var ritm = gel('selectRITM');
if (ritm)
{
Event.observe('selectRITM', 'change', function() {
var items = document.getElementsByTagName('item');
var myField = '';
var myFieldID = '';
var field;
for (var i = 0; i < items.length; i++)
{
// First, clear out all fields
if (items[i].getAttribute("qname").indexOf('jf1_') == 0)
{
if (items[i].getAttribute("qname") != 'jf1_width_macro')
{
myField = items[i].id;
myFieldID = '';
if (myField.length > 0)
{
myFieldID = ("IO:" + myField);
}
if (myFieldID.length > 0)
{
field = gel(myFieldID);
}
if (field)
{
field.value = "";
variableOnChange('IO:' + myField);
}
}
}
}
for (var i = 0; i < items.length; i++)
{
// Now populate with what goes
for (var j = 0; j < RITM_records.length; j++)
{
if (items[i].getAttribute("qname").indexOf('jf1_') == 0)
{
if (items[i].getAttribute("qname") != 'jf1_width_macro')
{
if (RITM_records[j][items[i].getAttribute("qname")])
{
myField = items[i].id;
myFieldID = '';
if (myField.length > 0)
{
myFieldID = ("IO:" + myField);
}
if (myFieldID.length > 0)
{
field = gel(myFieldID);
}
if (field)
{
field.value = RITM_records[j][items[i].getAttribute("qname")];
variableOnChange('IO:' + myField);
}
}
}
}
}
}
// Disable the SAVED select box (if any)
var selEl_SAVED = gel('selectSAVED');
if (selEl_SAVED)
{
if (this.value.length > 0)
{
selEl_SAVED.disabled = 'true';
}
else
{
selEl_SAVED.disabled = '';
}
}
});
}
var saved = gel('selectSAVED');
if (saved)
{
Event.observe('selectSAVED', 'change', function() {
var items = document.getElementsByTagName('item');
var myField = '';
var myFieldID = '';
var field;
for (var i = 0; i < items.length; i++)
{
// First, clear out all fields
if (items[i].getAttribute("qname").indexOf('jf1_') == 0)
{
if (items[i].getAttribute("qname") != 'jf1_width_macro')
{
myField = items[i].id;
myFieldID = '';
if (myField.length > 0)
{
myFieldID = ("IO:" + myField);
}
if (myFieldID.length > 0)
{
field = gel(myFieldID);
}
if (field)
{
field.value = '';
variableOnChange('IO:' + myField);
}
}
}
}
for (var i = 0; i < items.length; i++)
{
// Now populate with what goes
for (var j = 0; j < SAVED_records.length; j++)
{
if (items[i].getAttribute("qname").indexOf('jf1_') == 0)
{
if (items[i].getAttribute("qname") != 'jf1_width_macro')
{
if (SAVED_records[j][items[i].getAttribute("qname")])
{
myField = items[i].id;
myFieldID = '';
if (myField.length > 0)
{
myFieldID = ("IO:" + myField);
}
if (myFieldID.length > 0)
{
field = gel(myFieldID);
}
if (field)
{
field.value = SAVED_records[j][items[i].getAttribute("qname")];
variableOnChange('IO:' + myField);
}
}
}
}
}
}
// Disable the SAVED select box (if any)
var selEl_SAVED = gel('selectSAVED');
if (selEl_SAVED)
{
if (this.value.length > 0)
{
selEl_SAVED.disabled = 'true';
}
else
{
selEl_SAVED.disabled = '';
}
}
});
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2016 06:33 AM
I figured it out... and it's my fault. It was my code. Setting field.value = '' does indeed work.