Home › Forums › Classic DFFS › Auto resolve external content type and people picker columns
- This topic has 2 replies, 2 voices, and was last updated 8 years, 2 months ago by Alexander Bautz.
-
AuthorPosts
-
-
October 16, 2016 at 12:47 #13669
This code snippet was created by Penny Kingston to fix an issue where unresolved external content type columns in a form resulted it a failed postback, and a refresh of the form. This caused problems with emails as these would be sent on the first postback.
This code attaches a “focusout” event on the input that auto resolves the picker value, and prevents the form from saving if it has not resolved properly.
I have made some minor adjustments to the code – like adding a 1000 milliseconds delay before applying the code to ensure the picker is ready.
setTimeout(function(){ autoResolveECT("ECTTest"); autoResolvePP("PeoplePickerTest"); },1000); function autoResolveECT(a) { var b = spjs.$(spjs.utility.data.fields[a]); b.find("div[id$='Picker_upLevelDiv']").focusout(function() { b.find("a[id$='Picker_checkNames']").click(); }); } function autoResolvePP(a) { var b = spjs.$(spjs.utility.data.fields[a]); b.find("input.sp-peoplepicker-editorInput").focusout(function() { SPClientPeoplePicker.SPClientPeoplePickerDict[b.find("div.sp-peoplepicker-topLevel").attr("id")].AddUnresolvedUserFromEditor(true); }); } function isPeoplePickerResolved(a) { var b = spjs.$(spjs.utility.data.fields[a]), c = true; spjs.$.each(SPClientPeoplePicker.SPClientPeoplePickerDict[b.find("div.sp-peoplepicker-topLevel").attr("id")].GetControlValueAsJSObject(), function(a, b) { if (false === b.IsResolved){ c = false; } }); return c; } function isExternalContentResolved(a) { var b = spjs.$(spjs.utility.data.fields[a]), c = "true" === b.find("span.ms-usereditor").attr("value").toLowerCase() ? false : true, d = true; b.find("div[id='divEntityData']").each(function(a, b) { c = true; if ("false" === spjs.$(b).attr("isresolved").toLowerCase()){ d = false; } }); return c && d; } function PreSaveAction() { return isPeoplePickerResolved("PeoplePickerTest") && isExternalContentResolved("ECTTest"); }
This code targets a people picker field named “PeoplePickerTest” and an external content type column named “ECTTest”. Change these names to match your column names.
Alexander
-
October 19, 2016 at 01:47 #13709
Thanks for sharing! Would it be possible to have this added into DFFS?
-
October 21, 2016 at 22:00 #13760
I’ll see what I can do about adding it, but I’ll have to do some testing as it might behave a bit different in SP 2010 and 2013 / 2016.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.