Home › Forums › Cascading dropdowns › Limiting the number of levels that can be selected.
- This topic has 3 replies, 2 voices, and was last updated 5 years, 4 months ago by
Alexander Bautz.
-
AuthorPosts
-
-
January 26, 2021 at 19:52 #32596
We have a request to limit the number of items that can be selected in a cascade must-select to 2. Is this possible?
Current code (Ignore any errors, had to manually type it):function AlLoc(){
var resType = getFieldValue(“Resource_x0020_Type”);if (resType == “CLP Contractor” || resType == “Contractor” || resType == “FTE B4 – B9” || resType == “SP Onshore”){
var mgr4 = getFieldValue(“DFFSMgr4LName”);
var Loc2 = getFieldValue(“LocCat2”);spjs.casc.init({
‘manualMode’:true,
‘lookupList’:’Lookup-Location’,
‘lookupListBaseUrl’:'{currentSite}’.
‘lookupListFields’:[“LocCat2″,”ST_x002d_City_x002d_Address”],
‘thisListFields’:[“LocCat2″,”AlternateLocations:multi”],
‘droupDownDefaultvalue’:”,
‘filter’:'{“filterField”:”ValidForTE”,”filterValue”:”‘ + mgr4 + ‘”,”operator”:”substringof”}’,
‘hideEmptyDropdowns’:false,
‘autoselectSingleOption’:true,
‘clearInvalidSelection’:true,
‘sideBySide’:true,
‘debug’:false,
});
}
} -
January 26, 2021 at 20:21 #32598
You can add this to your Custom JS:
setInterval(function () { var len = jQuery("#AlternateLocations_casc").find("option").length; if (len > 2) { jQuery("#AlternateLocations_casc").find("option:last").prop("selected", true).trigger("dblclick"); spjs.dffs.alert({ "title": "To many!", "msg": "You can only select 2 items.", "ok": function () { // Close dialog } }); } }, 1000);Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.