Reply To: Issues with creating multiple Cascading rules tied to same lookup list

Forums Cascading dropdowns Issues with creating multiple Cascading rules tied to same lookup list Reply To: Issues with creating multiple Cascading rules tied to same lookup list

#10074
Alexander Bautz
Keymaster

Here is a possible solution (if I understand you correctly).
1:
Add a list named “LookupList_SPJSLookupOneToMany” with two columns “Level1” and “Level2”, and fill it like the attachment shows.

2:
Add four field to your main list: “SPJSLookupParent”, “SPJSLookupChild1”, “SPJSLookupChild2” and “SPJSLookupChild1”.

3:
Add this to the Custom JS:

spjs.lookup.init({
	"fieldToConvertToDropdown":["SPJSLookupParent"],	
	"listName":"LookupList_SPJSLookupOneToMany",
	"listBaseUrl":"/DFFS",
	"optTextFieldInternalName":"Level1",
	"sortFieldName":"Level1",
	"filterObj":{
		"on":false,
		"folder":"", // Leave empty to search in all folders
		"CAML":null, // If used, the rest of the filterObj settings are disregarded
		"fin":"Completed",
		"isLookup":false,
		"operator":"Neq",
		"filterVal":"1"
	},
	"dropDownDefaultvalue":"...",
	"addYouOwnValue":{
		"on":false,
		"linkText":"Write your own value"
	},
	"addToExternalList":{
		"on":false,
		"customFunction":null, // Function name as a string. If a function name is supplied, this will be used in stead of the default function. The function will be passed the argument object as a parameter.
		"linkText":"Add new item",
		"saveNewItemText":"Save new item"
	},
	"debug":false
});

$("#SPJSLookupParent_spjs_lookup").change(function(){
	var val = $(this).find("option:selected").text();
	// Delete current instances of child selects
	spjs.lookup.kill("SPJSLookupChild1");
	spjs.lookup.kill("SPJSLookupChild2");
	spjs.lookup.kill("SPJSLookupChild3");
	// Add new
	spjs.lookup.init({
		"fieldToConvertToDropdown":["SPJSLookupChild1","SPJSLookupChild2","SPJSLookupChild3"],	
		"listName":"LookupList_SPJSLookupOneToMany",
		"listBaseUrl":"/DFFS",
		"optTextFieldInternalName":"Level2",
		"sortFieldName":"Level2",
		"filterObj":{
			"on":true,
			"folder":"", // Leave empty to search in all folders
			"CAML":null, // If used, the rest of the filterObj settings are disregarded
			"fin":"Level1",
			"isLookup":false,
			"operator":"Eq",
			"filterVal":val
		},
		"dropDownDefaultvalue":"...",
		"addYouOwnValue":{
			"on":false,
			"linkText":"Write your own value"
		},
		"addToExternalList":{
			"on":false,
			"customFunction":null, // Function name as a string. If a function name is supplied, this will be used in stead of the default function. The function will be passed the argument object as a parameter.
			"linkText":"Add new item",
			"saveNewItemText":"Save new item"
		},
		"debug":false
	});
});

If you change the name of any of the fields, adapt the code by changing the names.

Hope this helps,
Alexander