Home › Forums › Cascading dropdowns › Issues with creating multiple Cascading rules tied to same lookup list
- This topic has 12 replies, 3 voices, and was last updated 8 years, 9 months ago by Alexander Bautz.
-
AuthorPosts
-
-
January 14, 2016 at 17:33 #9886
Hi,
I have a screenshot attached that I hope helps.
I’m able to get Cascading Dropdowns working fine with one branch that looks up one list and fills in the field I need, but The solution breaks when I try to make multiple branches (rules) within Cascading Dropdowns that all call the same lookup list. I have 4 fields on my primary list, each of I’d like to fill with values from my lookup list. Here’s the example:
Current List fields (single line of text) that I want to populate with dropdown options from the lookup:
Primary Exception Code
Secondary Exception Code
Third Exception Code
Fourth Exception CodeThe user has the option to pick dropdown values from each of the four fields. The four fields all call the same lookup list, but populate different values in the current list.
Attachments:
-
January 16, 2016 at 03:45 #9919
I think you’re just configuring this incorrectly – it looks like you’re targeting the same field (Channel) in both config sections, which would be impossible, and also using the same list of options for both primary and secondary exception code fields – possible but doesn’t sound likely. Is it really cascading dropdowns that you want?
To get a four level cascade, you simply list the four fields in the “lookup” list, and then the four fields in the form you want to populate – the “current” list.
From Alexander’s post;lookupListFields: The FieldInternalNames of the fields in the above list.
thisListFields: The FieldInternalNames of the fields to convert to dropdowns.And importantly:
The length of the arrays “lookupListFields” and “thisListFields” must be the same.
ie just pair up the from and to fields, and list them in the right order.
So in your lookup list field you’d have eg Column1,Column2,Column3,Column4
And in the current list field eg Primary,Secondary,Third,FourthSee the original post
-
January 20, 2016 at 21:08 #9949
Hi,
I did a quick check to see if I could set up a scenario like your image in the first post. I had no problem setting up this test:
Attachments:
-
January 20, 2016 at 22:08 #9955
Hi Alexander
I think Jon’s scenario in the image and your example are slightly different in that Jon is targeting the same field (Channel) on the form twice – as far as I can see that’s an impossibility? Your example targets four completely separate fields – two pairs which cascade nicely.
Jon’s scenario translated into your example would equate to;
Casc1,Casc2
Casc1,Casc4
in the config for the current list fields. Am I missing something? -
January 20, 2016 at 22:25 #9957
You are correct – this is not possible and explains the error.
Alexander
-
January 21, 2016 at 00:54 #9973
Thank you, both. I think what I need is SPJS-lookup. The user will pick the “channel” option”, and then I will set drop down options within 8 different fields. These options could be different based on the “Channel” they choose. Is this something that SPJS-lookup can do? From what I’m reading, it seems like it can….
-
January 27, 2016 at 02:43 #10030
Hi Jon
This isn’t something I’ve done and looks pretty complex (to me) to achieve.
If I understand you correctly, it sounds like you want to do something similar to the example in this post, but with eight sub-menus filtered off the first selection rather than just one;
Combining SPJS-Lookup with Cascading DropdownsAdam
-
January 27, 2016 at 18:59 #10046
Yes, that’s correct. User picks 1 option, which triggers eight sub-menus filtered
off the first selection. The eight sub-menus all have codes like “reason code 1, “reason code 2″…but vary based on that first selection. -
January 29, 2016 at 00:09 #10074
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- This reply was modified 8 years, 10 months ago by Alexander Bautz.
Attachments:
-
February 18, 2016 at 05:47 #10304
Sorry for my delay in responding. This solution worked amazingly well! One question though: At the moment, if I open an existing item in EditForm, the fields to convert to dropdown are still single line of text until I toggle the parent field, forcing a change event. After this, I see the dropdowns and the options. How do I get the code fire on form load, rendering the single lines as dropdowns when EditForm opens, so that a user doesn’t have to do that?
-
February 20, 2016 at 00:18 #10356
I’m glad it worked. Try changing the last line in my code example from this:
});
to this:
}).trigger("change");
Alexander
-
February 22, 2016 at 18:11 #10375
PERFECT! Thank you again. What is the JS code for a hug / high five to you?! Cheers!
-
February 23, 2016 at 14:50 #10399
Thanks, I’m glad it worked out.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.