- This topic has 42 replies, 4 voices, and was last updated 3 years, 10 months ago by MikeS.
-
AuthorPosts
-
-
February 16, 2017 at 00:44 #15657
Would you consider adding a “Filter Field” and “Filter Value” to the Cascading Drop downs plugin? This way you could use one list for multiple Cascading Drop Down configurations ore even use it to temporarily disable options by adding an Active flag field.
I emailed this to you but wanted to post it for your records.
Love the recent enhancements. Thank you for continuing to improve upon your already excellent solution.
-
February 19, 2017 at 18:52 #15712
This is a good idea and I’ll try to get it done soon.
Best regards,
Alexander -
February 16, 2018 at 08:11 #19881
Is there any trick to apply more than one filter for a cascading dropdown, even if it needs to be done when the results have been returned?
-
February 17, 2018 at 09:23 #19908
I’m not sure I understand exactly what you mean, but if you need to change the dataset based on other fields in your list you can call the function manually as described here.
Alexander
-
February 18, 2018 at 03:30 #19914
Can you use multiple filter criteria when you call spjs.casc.init? I tried using the following syntax for the filter option, but the operation failed:
“filter”:[{“filterField”:”Title”,”filterValue”:”testing”,”operator”:”ne”},{“filterField”:”Country”,”filterValue”:”New Zealand”,”operator”:”eq”}]
Or is there another option for updating the results of this call?
-
February 19, 2018 at 19:50 #19925
Sorry, but only one filter criteria can be used at the moment. Maybe you can create a calculated column in the list to filter on?
Alexander
-
April 5, 2018 at 10:04 #20450
Unfortunately I need to filter based on the properties of the current user, so I can’t implement as a calculated column.
I’m trying to use a Jquery statement to remove the option from the DOM, but I’m having problems figuring out where to place this. I’ve tried calling it from a rule that runs when the form is ready or initialized, but in both cases, it seems like the DOM hasn’t been populated with the cascading dropdown values yet. Any suggestions?
-
April 7, 2018 at 06:40 #20481
Thank you Alexander, that works perfectly.
-
April 7, 2018 at 12:39 #20488
Thanks for the feedback – I’m glad it worked out.
Alexander
-
April 9, 2018 at 03:48 #20494
Hi Alexander, I think there is an issue with the updated code if you use the standard filter criteria. The error appears in line 184 in the call to spjs.casc.init:
`var c, s, err = false, camlFilter = b.filter.charAt(0) === “<” ? true : false;
the b variable contains an object, which seems to fail on the b.filter.charAt(0) statement.
-
April 9, 2018 at 17:52 #20503
Ah – forgot that the filter was an object when using it in Custom JS. I have updated the file to v3.7.13.
Alexander
-
January 12, 2021 at 21:00 #32474
Alex,
I’m using the manual CASC implementation (spjs.casc.init) in custom JS and trying to implement the following. Note that this CASC implementation is looking up to the same list with multi-select.
1. Set filter to another field (a SharePoint OOTB single lookup field – but could convert this to a single-line plain text if needed) in the record so only those options that contain the filter appear in the selection box, basically a dynamic filter. Not sure if CAML can do that. I looked at Multiple filters from same datasource (CAML) — perhaps that could be adapted? I’ve also looked at SPJS-Lookup but that may be more than I need in combination with spjs.casc.init
2. Once an option is selected automatically auto select all secondary options – not just if only a single option is found (as the menu-driven CASC allows).
Thanks,
MikeS -
January 13, 2021 at 18:23 #32476
You can do it like this:
var lookupValue = getFieldValue("LookupColumn1"); var query = "<Where><Eq><FieldRef Name='LookupColumn2' LookupId='FALSE' /><Value Type='Lookup'>"+lookupValue+"</Value></Eq></Where>"; spjs.casc.init({ ..., ..., ..., "filter":query, ..., ... })
In this example LookupColumn1 is the single lookup field and LookupColumn2 is the multi-lookup field.
Alexander
-
January 13, 2021 at 20:25 #32480
How can I compare just the first 12 characters of LookupColumn2 to LookupColumn1? (LookupColumn2 is an aggregation of metadata that includes LookupColumn1 as a prefix.)
Thanks
MikeS -
January 13, 2021 at 20:37 #32482
This is unfortunately not possible when querying a lookup column – you can only use “equals” and not “beginswith” or “contains”.
Alexander
-
January 13, 2021 at 21:22 #32486
I can easily copy the lookup column to a plain text field. How would a CONTAINS query work then?
MikeS
-
January 14, 2021 at 13:12 #32488
When querying a multiline text field you can use contains – like this.
var query = "<Where><Contains><FieldRef Name='Your_MultiLineTextField' /><Value Type='Text'>"+lookupValue+"</Value></Contains></Where>";
Alexander
-
-
January 13, 2021 at 18:27 #32478
Forgot question 2:
There is not built in code to select all items in a lookup column, but it can be done with custom.I’m not sure I understand what you are trying to do, but if you are planning to write all items to a multiline text field you might as well skip the cascading dropdown and just use custom js to get the items and write them with code – if you can explain in more detail what you are trying to do I’ll see if this might be a better option.
Alexander
-
January 13, 2021 at 21:19 #32484
I have a parent item with multiple children that are related to the parent by a lookup column. (These children originate independently of the parent and thus vLookup will not work as I am not generating the children from the parent.)
Each child has a multi-line text field that must be pulled forward to the parent thru DFFS multi-select. ** When the multi-line text field is changed in the child it would be optimal if that change was immediately reflected in the parent (like SharePoint OOTB changes).**
Lacking that ability with current spjs.casc.init code, the user edits the parent and re-selects the children in the multi-select box and then the changes in the multi-line text field are pulled into the parent.
Thanks,
MikeS-
January 14, 2021 at 16:53 #32492
-
January 14, 2021 at 23:01 #32495
A regular vLookup would work as it would dynamically update in the parent when a child is updated. I would then use JS to write the updated child fields to a single multi-line parent field.
I’m just having a bit of a problem with the vLookup setup. Some details:
1. This is a vLookup into the same list (no child list). Does that require the [currentItem:FIN] format as shown in the tooltip?
2. However, the lookup field (Title field) is a single line text field in which only the first 12 characters provide the match needed for the vLookup. Seems like this would require use of the CAML-query section of the vLookup. Would the same format,var query = "<Where><Contains><FieldRef Name='Your_MultiLineTextField' /><Value Type='Text'>"+lookupValue+"</Value></Contains></Where>";
then be inserted? Tried this and a number of configurations and keep getting ‘no items found.’
Thanks,
MikeS
-
-
January 14, 2021 at 23:17 #32497
1: Yes, same format.
2: Like this:<Where><Contains><FieldRef Name='Title' /><Value Type='Text'>[currentItem:FIN]</Value></Contains></Where>
Alexander
-
January 15, 2021 at 17:18 #32505
Thank you Alex, this is working well. A few more tweaks are needed.
Is this caution from the vLookup manual a consideration if our internal list threshold for an on-site SP 2013 is 15,000 items?: “Please note that you cannot use the default lookup column connection if your parent list ever exceeds 5,000 items.”
1. Can vLookup be customized in such a way that it will only absorb the child data based on a string found in the Title field? This will allow only the parent to display the children found in the same list. Now the children and the parent all display the same information which would confuse the user. I could hide the Rollup Tab for the children and just display it for the parent, but that seems less than optimal. Your thoughts?
2. Set value from vLookup table to a field in the current form would allow a single line displayed in a vLookup table to be inserted into a field in the current item. Is there a way to take multiple multi-line values (from the children) shown in the vLookup table and automatically aggregate them in a single multi-line text field in the current (parent) item with a pipe delimiter between each child’s value?
Thanks
MikeS -
January 16, 2021 at 09:49 #32511
The 5000 items threshold only applies to SharePoint online (where it cannot be changed).
1: The CAML query I posted in my previous comment will only return the items where the Title of the child contains the value found in the field specified in [currentItem:FIN].2: You can use custom js to find the value from the vLookup table and then append it to your current form like this:
function vLookupIsLoadedCallback(fin){ if(fin === "vLookupTasks"){ var arr = []; jQuery("#dffs_vLookupTasks .vLookupTableRow").each(function(i, row){ arr.push(jQuery(row).find(".childTableCell:eq(1)").text()); }); setFieldValue("MultilineField", arr.join("|")); } }
Replace vLookupTasks with your vLookup field internal name, MultilineField with your multiline text field internal name and the 1 in .childTableCell:eq(1) with the column index from the left (starts on 0).
Please note that this will only run when the vLookup table is rendered (when it is visible in a tab).
Alexander
-
January 18, 2021 at 19:38 #32518
The script in No. 2 above is working well in the Edit form.
Can a CAML-like query be placed in this script so that it only runs based on characters (CONTAINS) in a CurrentItem:FIN field?
Thanks
MikeS -
January 18, 2021 at 20:17 #32520
I don’t understand what you mean. The vLookup table is populated based on the query you set up in the vLookup config – doesn’t this mean the table is already filtered to show the correct items?
Alexander
-
January 18, 2021 at 20:37 #32522
Here is an example of the Title field:
Part1,All [parent]
Part1,A [child]
Part1,B [child]
Part1,C [child]
Part2,All [parent]
Part2,A [child]
Part2,B [child]
Part2,C [child]The vLookup CAML query is working well by filtering on the ‘Part1’ or ‘Part2’ common to the family of items in this single list. However, each child as well as the parent renders all of the items, when only the parent should display the children AND the parent in the vLookup table. The children should not render the vLookup table.
MikeS
-
January 19, 2021 at 20:43 #32524
I’m still not sure I understand, but the vLookup CAML query can take multiple filters like this:
<Where><And><Contains><FieldRef Name='OneField' /><Value Type='Text'>[currentItem:FIN]</Value></Contains><Contains><FieldRef Name='AnotherField' /><Value Type='Text'>[currentItem:AnotherFIN]</Value></Contains></And></Where>
Wouldn’t that work?
Alexander
-
-
January 19, 2021 at 21:57 #32526
Unfortunately that enhanced CAML query results in only the parent being rendered in the vLookup table. I need the parent and children to be rendered for only the parent item.
I can set up a rule that will trigger on a parent specific field. That should then render the vLookup table properly. However, when I place the “function vLookupIsLoadedCallback” JS in the “Run these functions” after a {inline} field nothing displays in the multiline field. Does that script need a tweak to run in that location?
MikeS
-
January 19, 2021 at 22:19 #32528
I’m sorry, but I really don’t understand. If your parent items have a specific text in a field and the child items don’t you should be able to only load the vLookup table for the parent items if you set up a CAML query.
If the vLookup field is visible in the tab also for the child items it would be empty. You could of course hide the field based on a rule triggering on the field that only the parent has a specific value in to ensure the child items don’t see the vLookup table.
If this does not make sense I need you to show me some screenshots of the difference between a parent and a child and a bit more details so I can understand the relationship between the items.
Alexander
-
-
January 21, 2021 at 21:31 #32536
There are six screen shots attached that should help clarify the issue. The last screenshot of the CHILD should not run the vLookup and/or there should be no aggregation of content in the PartDescriptionCombo field. Only the PARENT should show CHILDREN and aggregate content in the PartDescriptionCombo field.
Thanks for your help,
MikeSAttachments:
-
January 21, 2021 at 21:32 #32542
Last two attachments
MikeS
Attachments:
-
January 23, 2021 at 10:34 #32570
What I still don’t fully understand is how you are supposed to know which items are parent and child when you look at the list items in a list view.
To be able to stop the code from running – and hide the vLookup for the child items you need to have for example a yes/no checkbox field named “IsParent= Yes” for parents and “IsParent=No” for children.
If you have this you can use a CAML like this in the vLookup:
<Where><And><BeginsWith><FieldRef Name='Title' /><Value Type='Text'>[currentItem:BaseRack]</Value></BeginsWith><Eq><FieldRef Name='IsParent' /><Value Type='Boolean'>0</Value></Contains></And></Where>
This query will find all items where the Title begins with the current items BaseRack AND the IsParent field = No.
Also you can use this check in the custom js function like this:
function vLookupIsLoadedCallback(fin){ if(getFieldValue("IsParent")){ // Only run this for the parent item if(fin === "vLookupParentRollup"){ var arr = []; jQuery("#dffs_vLookupParentRollup .vLookupTableRow").each(function(i, row){ arr.push(jQuery(row).find(".childTableCell:eq(2)").text()); }); setFieldValue("PartDescriptionCombo", arr.join("|")); } } }
Alexander
-
January 23, 2021 at 20:02 #32572
Parent items are identified in two ways:
- Rack Code=AA
- Rack no includes the string “Parent”
Using your modified CAML query and adding the IsParent field (1=true) returns only the Parent record in vLookup for Parent or Children items. Both the Parent and the Children should be returned in vLookup for the Parent item.
MikeS
-
January 24, 2021 at 12:04 #32574
OK, then you can use the RackCode field to control it. Remove the IsParent field and use the RackCode field to control the visibility of the vLookup filed in your form by setting up a DFFS rule hiding the field if the RackCode is not AA.
Now change the CAML like this to show all where the Title starts with the BaseRack name:
<Where><BeginsWith><FieldRef Name='Title' /><Value Type='Text'>[currentItem:BaseRack]</Value></BeginsWith></Where>
Change the Custom JS code like this (Change RackCode to match the internal name of your field):
function vLookupIsLoadedCallback(fin) { if (fin === "vLookupParentRollup") { if (getFieldValue("RackCode") === "AA") { // Only run this for the parent item var arr = []; jQuery("#dffs_vLookupParentRollup .vLookupTableRow").each(function (i, row) { arr.push(jQuery(row).find(".childTableCell:eq(2)").text()); }); setFieldValue("PartDescriptionCombo", arr.join("|")); } } }
This will now hide the vLookupParentRollup field for child items and also only write to the PartDescriptionCombo field for the parent items.
Please note that there is no way to fill the vLookup table for only the parent items so if you do NOT hide the vLookupParentRollup in the child items with the DFFS rule it will still keep listing the items in the child items as well as in the parent.
Alexander
-
January 26, 2021 at 01:49 #32585
That nailed it! Works perfectly. The “if (getFieldValue(…” statement in the vLookupIsLoadedCallback function was instrumental.
Much appreciated,
MikeS -
January 26, 2021 at 18:36 #32592
Thanks for the feedback – I’m glad you got it worked out.
Alexander
-
February 19, 2021 at 00:01 #32804
Alexander,
I need to include a childTableCell column in the JS below for purposes of aggregating it in the PartDescriptionCombo field. However, I need to hide the same childTableCell column on the form (with CSS or JS I assume) as the user does not wish to view it. How could that be accomplished?
function vLookupIsLoadedCallback(fin) { if (fin === "vLookupParentRollup") { if (getFieldValue("RackCode") === "AA") { // Only run this for the parent item var arr = []; jQuery("#dffs_vLookupParentRollup .vLookupTableRow").each(function (i, row) { arr.push(jQuery(row).find(".childTableCell:eq(2)").text()); }); setFieldValue("PartDescriptionCombo", arr.join("|")); } } }
Thanks for your help,
MikeS- This reply was modified 3 years, 10 months ago by MikeS.
-
February 19, 2021 at 16:54 #32808
I have not added a class to the header that you can address directly, but you can do it like this (change vLookupTasks for your vLookup field name):
/* Hide header - the number 6 is the count of columns from left*/ #vLookupTablePlaceholder_vLookupTasks tr .childTableHeader:nth-child(6){ } /* Hide body - change vLookupTasks for your vLookup field name and vLookupTasks_Status to match your vLookup field name and the child list field internal name separated with _ */ #vLookupTablePlaceholder_vLookupTasks .vLookupTasks_Status{ display:none; }
Alexander
- This reply was modified 3 years, 10 months ago by Alexander Bautz.
-
February 22, 2021 at 20:00 #32822
Alexander,
Having a bit of problem integrating these statements
/* Hide header - the number 6 is the count of columns from left*/ #vLookupTablePlaceholder_vLookupTasks tr .childTableHeader:nth-child(6){ } /* Hide body - change vLookupTasks for your vLookup field name and vLookupTasks_Status to match your vLookup field name and the child list field internal name separated with _ */ #vLookupTablePlaceholder_vLookupTasks .vLookupTasks_Status{ display:none; }
with the larger code:
function vLookupIsLoadedCallback(fin) { if (fin === "vLookupParentRollup") { if (getFieldValue("RackCode") === "AA") { // Only run this for the parent item var arr = []; jQuery("#dffs_vLookupParentRollup .vLookupTableRow").each(function (i, row) { arr.push(jQuery(row).find(".childTableCell:eq(2)").text()); }); setFieldValue("PartDescriptionCombo", arr.join("|")); } } }
Where do they go?
Also, do I replace vLookupTasks with my vLookup field as so: vLookupMyField, or is it vMyField?
Thanks
MikeS-
February 22, 2021 at 20:32 #32826
The code I send is for Custom CSS and not Custom JS.
Replace vLookupTasks with the internal name of your vLookup field – you find the internal name in the Fields tab in your DFFS config.
Alexander
-
-
February 23, 2021 at 18:25 #32843
Thank you! This works perfectly.
MikeS
-
-
AuthorPosts
- You must be logged in to reply to this topic.