Home › Forums › Classic DFFS › getFieldValue for lookups
- This topic has 5 replies, 2 voices, and was last updated 5 years, 8 months ago by Alexander Bautz.
-
AuthorPosts
-
-
March 13, 2019 at 20:56 #24291
I have a multi-value lookup field “Groups” set as a dropdown. Use of
getFieldValue("Groups")
results in a delimited string of Values. Is there a function to get IDs or key/value pairs?
I understand there is a people-picker syntax that does return a key/value pair for People Picker:getFieldValue({"fin": xxx, "key": yyy})
Cant find yet what will work for a lookup field. Appreciate assist
-
March 13, 2019 at 22:12 #24299
Hi,
I’m not sure what you mean by “multi-value lookup field “Groups” set as a dropdown” – is this some kind of third party field type or is it the default lookup field with multiselect turned on so you have two lists side by side – one with unselected options and one with selected ones?Alexander
-
March 13, 2019 at 22:31 #24301
Right, Alex, just a regular Lookup field named “Groups”, with enabled multi-value selection.
The field is a lookup to another list. I’d like to pull not just selected values from the source list, but also selected items’ IDs.getFieldValue("Groups")
only returns Values.
Wondering if there is a DFFS function to get value pairs or IDs.
I understand that if nothing else, I can runspjs.utility.queryItems()
passing selected Values in CAML, but that seems too cumbersome just to get IDs.
Please advise.Attachments:
-
March 13, 2019 at 22:45 #24304
You can use this function:
function getMultiLookupKeyValue(fin) { var a = []; jQuery("#dffs_" + fin + " select:last option").each(function (i, o) { a.push({ "id": o.getAttribute("value"), "title": o.innerText }); }); return a; } // Call it with the fieldinternalname getMultiLookupKeyValue("LookupColumn2");
Alexander
-
March 13, 2019 at 23:15 #24306
Thanks Alex, works like a charm! What exactly “#dffs_” does at run time? – back to DFFS API 🙂
-
March 14, 2019 at 17:18 #24311
This is just a jQuery selector looking for the table row with ID = “dffs_FieldInternalName”. This ID attribute is inserted by the DFFS script and this is why it has the dffs_ prefix. This is not really a DFFS functionality, it’s just “traversing the DOM to find the element you are looking for” – you don’t need to use jQuery if you want to use plain javascript, but it’s most likely easier to use jQuery. You can read about the different jQuery methods here: https://api.jquery.com/category/traversing/
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.