Skip to main content
deleted 284 characters in body
Source Link
karthik
  • 367
  • 1
  • 13

I also faced the same issue sp.js and sp.runtime.js etc. were not loading with page load I tried different approaches finally with below code I am able to load them, might it help

$(function(){getSPOffset();LoadData();});function initializePeoplePicker(peoplePickerElementId, allowMultipleValues, isPeopleOnly, GroupID, user){//debugger;/*SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){*/SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function(){var schema ={};if(isPeopleOnly){schema['PrincipalAccountType'] = 'User';}else{schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';}schema['SearchPrincipalSource'] = 15;schema['ResolvePrincipalSource'] = 15;schema['AllowMultipleValues'] = allowMultipleValues;schema['MaximumEntitySuggestions'] = 50;schema['Width'] = '280px';if(GroupID!= null){if(GroupID > 0){schema['SharePointGroupID'] = GroupID}}SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, user, schema);});}function LoadData(){initializePeoplePicker('userdiv', false, true, null, null);
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.core.js"></script>
<script type="text/javascript" src="/_layouts/15/1033/strings.js"></script>
<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>
<script type="text/javascript">
$(function() {
    getSPOffset();
    LoadData();
});

function initializePeoplePicker(peoplePickerElementId, allowMultipleValues, isPeopleOnly, GroupID, user) {
//debugger;
                        SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
                            var schema = {};
                            if(isPeopleOnly) {
                                schema['PrincipalAccountType'] = 'User';
                            }
                            else {
                                schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
                            }
                            schema['SearchPrincipalSource'] = 15;
                            schema['ResolvePrincipalSource'] = 15;
                            schema['AllowMultipleValues'] = allowMultipleValues;
                            schema['MaximumEntitySuggestions'] = 50;
                            schema['Width'] = '280px';
                            if(GroupID != null) {
                                if (GroupID > 0) {  
                                    schema['SharePointGroupID'] = GroupID  
                                }
                            }
                            SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, user, schema);
                        });
    
}
}

I also faced the same issue sp.js and sp.runtime.js etc. were not loading with page load I tried different approaches finally with below code I am able to load them, might it help

$(function(){getSPOffset();LoadData();});function initializePeoplePicker(peoplePickerElementId, allowMultipleValues, isPeopleOnly, GroupID, user){//debugger;/*SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){SP.SOD.executeOrDelayUntilScriptLoaded(function(){*/SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function(){var schema ={};if(isPeopleOnly){schema['PrincipalAccountType'] = 'User';}else{schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';}schema['SearchPrincipalSource'] = 15;schema['ResolvePrincipalSource'] = 15;schema['AllowMultipleValues'] = allowMultipleValues;schema['MaximumEntitySuggestions'] = 50;schema['Width'] = '280px';if(GroupID!= null){if(GroupID > 0){schema['SharePointGroupID'] = GroupID}}SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, user, schema);});}function LoadData(){initializePeoplePicker('userdiv', false, true, null, null);}

I also faced the same issue sp.js and sp.runtime.js etc. were not loading with page load I tried different approaches finally with below code I am able to load them, might help

<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.core.js"></script>
<script type="text/javascript" src="/_layouts/15/1033/strings.js"></script>
<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>
<script type="text/javascript">
$(function() {
    getSPOffset();
    LoadData();
});

function initializePeoplePicker(peoplePickerElementId, allowMultipleValues, isPeopleOnly, GroupID, user) {
//debugger;
                        SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
                            var schema = {};
                            if(isPeopleOnly) {
                                schema['PrincipalAccountType'] = 'User';
                            }
                            else {
                                schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
                            }
                            schema['SearchPrincipalSource'] = 15;
                            schema['ResolvePrincipalSource'] = 15;
                            schema['AllowMultipleValues'] = allowMultipleValues;
                            schema['MaximumEntitySuggestions'] = 50;
                            schema['Width'] = '280px';
                            if(GroupID != null) {
                                if (GroupID > 0) {  
                                    schema['SharePointGroupID'] = GroupID  
                                }
                            }
                            SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, user, schema);
                        });
    
}
Source Link
karthik
  • 367
  • 1
  • 13

I also faced the same issue sp.js and sp.runtime.js etc. were not loading with page load I tried different approaches finally with below code I am able to load them, might it help

$(function() { getSPOffset(); LoadData(); }); function initializePeoplePicker(peoplePickerElementId, allowMultipleValues, isPeopleOnly, GroupID, user) { //debugger; /*SP.SOD.executeOrDelayUntilScriptLoaded(function() { SP.SOD.executeOrDelayUntilScriptLoaded(function() { SP.SOD.executeOrDelayUntilScriptLoaded(function() { SP.SOD.executeOrDelayUntilScriptLoaded(function() { SP.SOD.executeOrDelayUntilScriptLoaded(function() { SP.SOD.executeOrDelayUntilScriptLoaded(function() {*/ SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() { var schema = {}; if(isPeopleOnly) { schema['PrincipalAccountType'] = 'User'; } else { schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup'; } schema['SearchPrincipalSource'] = 15; schema['ResolvePrincipalSource'] = 15; schema['AllowMultipleValues'] = allowMultipleValues; schema['MaximumEntitySuggestions'] = 50; schema['Width'] = '280px'; if(GroupID != null) { if (GroupID > 0) { schema['SharePointGroupID'] = GroupID } } SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, user, schema); }); } function LoadData() { initializePeoplePicker('userdiv', false, true, null, null); }