koltyakov / sp-rest-proxy

🌐 SharePoint API Proxy for local development
MIT License
170 stars 43 forks source link

How to build People Picker in local development using sp-rest-proxy #112

Closed spvjebaraj closed 4 years ago

spvjebaraj commented 4 years ago

Hi Andrew,

I am working in SharePoint online with sp-rest-proxy library. I am unable to build the People Picker control in local development with react app.

I have added the below script library in index.html file. But when I build the code, it throws error as "clienttemplates.js:1 Uncaught ReferenceError: ListModule is not define at InitListViewSettings (clienttemplates.js:1)" and other errors like, "clientforms.js:1 Uncaught ReferenceError: ExecuteOrDelayUntilScriptLoaded is not defined at clientforms.js:1"

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

In addition to that, I am unable to use "ExecuteOrDelayUntilScriptLoaded" in component files (js files).

How to use the ExecuteOrDelayUntilScriptLoaded function to run some operation during the component load like useEffect method. Please help me.

koltyakov commented 4 years ago

You mostly don't need that legacy stuff you mention in SharePoint development nowadays. Just WHY??!?

To get people picker data in a control, e.g. FluentUI/Office UI Fabric/or any custom one, you can use /_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.ClientPeoplePickerSearchUser endpoint, it's represented with profiles. clientPeoplePickerSearchUser method in PnPjs.

ExecuteOrDelayUntilScriptLoaded should not be used, it's a part JSOM (init.js in particular). Well... if you really need JSOM for any reason, JSOM scripts should be loaded to the local workbench.

With meaningless legacy, the idea should be following: how it's delivered to SP pages, can it be mimic or reproduced in a local workbench, if it only can be mimic some check logic based on hostname should be involved (do one way on SP page when deployed, do another way while in a dev mode in a local workbench.

spvjebaraj commented 4 years ago

Thanks Andrew for the details.