After reading the following forum post regarding Field and Form rules filtering I've decided to give this a go on my requester form
I'm trying to filter the results of my custom field named Location (WorkOrder_Fields_UDF_CHAR90) by what is selected from the Site field
Example- If someone selects 'Reading' from the Site field i only want options in the Location field to display if they contain the word Reading (Example location- Civic (Reading)).
var Site_ele = jQuery('[data-field=SITE]'); // Getting Site Element
var Location_ele = jQuery('[data-field=WorkOrder_Fields_UDF_CHAR90]'); // Getting Location Element
filter_Site_Location_values(); // Executing the Script on Form Load
Site_ele.bind('change',function(){
Location_ele.val('0'); // Setting the Location Element Value to default one
filter_Site_Location_values();// Executing the Script on Site Element Changes
});
function filter_Site_Location_values(){
var Site_val = Site_ele.val();
var Location_val = Location_ele.val();
if(Site_val === '0'){
Location_ele.find('option').hide(); //Hiding all Locations if the Site value is empty
}else{
Site_val = $CS.getText("SITE");
Location_ele.find('option').each(function(){ // Show and hide elements of Site
var prj_val = jQuery(this).attr('value');
if(prj_val.indexOf(Site_val) == -1 && prj_val != '0'){ // Checking the Location options with Site Value.
//jQuery(this).hide();
window.alert("Hiding: " + prj_val);
//$CS.hideOptions("WorkOrder_Fields_UDF_CHAR90", [prj_val]);
}else{
jQuery(this).show();
}
});
}
}
A very similar request is raised and answered in the referenced forum post , which I have tried but it hasn't worked (See below). I have tried to amend this and put popup boxes in place to give me some feedback as to what it's doing. Sadly, though it does appear to try and hide the fields when I select a site it fails to do so and I'm unsure why.