Ok I got two questions, might be related.

1.) How can I use the following library in React using import

<script type="text/javascript" src="_layouts/15/clienttemplates.js"></script>
<script type="text/javascript" src="_layouts/15/clientforms.js"></script>
<script type="text/javascript" src="_layouts/15/clientpeoplepicker.js"></script>
<script type="text/javascript" src="_layouts/15/autofill.js"></script>

I tried this but it didnt work

import "_layouts/15/clienttemplates.js";
import "_layouts/15/clientforms.js";
import "_layouts/15/clientpeoplepicker.js";
import "_layouts/15/autofill.js";

2.) How can include a working people picker in my application. I was able to make it work in angularjs but not sure if its possible in react. This is working in Angularj but in React its complaining about SPClientPeoplePicker_InitStandaloneControlWrapper not a function. I tried replacing it with "window.SPClientPeoplePicker_InitStandaloneControlWrapper" but saying its not a function

var schema = {};
schema["PrincipalAccountType"] = "User";
schema["SearchPrincipalSource"] = 15;
schema["ResolvePrincipalSource"] = 1;
switch (peoplePickerElementId) {
  case "ContentAuthortxt":
    schema["AllowMultipleValues"] = true;
    schema["AllowMultipleValues"] = false;
schema["MaximumEntitySuggestions"] = 50;
schema["Width"] = "100%";

  • Do you build SPFx solution? – Sergei Sergeev Sep 8 '18 at 6:59
  • Nope its not SPFx, just CEWP and js files uploaded in site assets. – Billy Sep 8 '18 at 7:00
  • When I try checking the "window.SPClientPeoplePicker_InitStandaloneControlWrapper" in the developer tool console it exist, but somehow inside my components its not visible – Billy Sep 8 '18 at 7:11
  • Here's an open-source people picker react control from SharePoint PnP: sharepoint.github.io/sp-dev-fx-controls-react/controls/… – theChrisKent Sep 8 '18 at 19:39
  • 1
    Hi @theChrisKent Chris :) People picker from reusable controls has a dependency on SPFx related things, that's why probably it's not valid here... – Sergei Sergeev Sep 9 '18 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.