Home › Forums › SPJS-Utility › Possible Bug in getFieldValue on Display Form for MultiUserField
- This topic has 5 replies, 2 voices, and was last updated 6 years, 2 months ago by Alexander Bautz.
-
AuthorPosts
-
-
August 27, 2018 at 10:01 #21955
Hi Alexander,
I’ve encountered a strange behaviour in getFieldValue for a MultiUserField in the Display Form for an Item:
If I execute getFieldValue (does not matter if only with Field name or with delimiters and “True” for dispform) it get the User Names concatenated to each other without any delimiter in one single string block. However for edit and new form it works without any problem.
Is there something I’m doing wrong or is there some strange behaviour in the disp form ?
Thank you very much in advance.
BR,
Chris -
August 27, 2018 at 18:52 #21958
Hi,
You are correct – the code used in getFieldValue for multichoice people pickers doesn’t work correctly. I think maybe SP has changed how the values are displayed in DispForm.I’ll fix it in the next release, but in the meantime you can use this format instead of getFieldValue:
spjs.dffs.beforeProperties.YourPeoplePickerFieldInternalName
Alexander
-
August 28, 2018 at 10:01 #21962
Hi Alexander,
Thank you for the feedback. Unfortunately your suggested format returns an empty array, but the field has 2 persons inside actually (see attached Screenshot)
Do you have any other suggestion for me ?
Thank you very much and BR,
ChrisAttachments:
-
-
August 29, 2018 at 16:03 #21972
You can put this function in your custom js:
function getPeoplePickerInDispForm(fin){ var b = []; jQuery("#dffs_"+fin+" td.ms-formbody a").each(function(i,a){ if(jQuery(a).attr("onclick").match("GoToLinkOrDialogNewWindow") !== null){ b.push(a.innerText); } }); return b; }
Then use this to get the value:
var pp = getPeoplePickerInDispForm("FieldInternalName");
Let me know how this works.
Alexander
-
August 30, 2018 at 12:13 #21982
Hi Alexander,
Thank you very much, your last solution works like a charm 🙂
BR,
Chris
-
-
August 30, 2018 at 20:37 #21994
Thanks for the feedback, I’ll include this change in the next version of SPJS-Utility.js.
Best regards,
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.