Question

I am trying to get SPutility to work in Sharepoint online. I could not get any scripts to work in neither script editor nor content editor web parts. I don't have access to custom forms advanced mode editing (yet - i hope i will get it soon from the admin). I managed to find a workaround by using Form HTML webpart and editing its source code and putting my script there. jQuery works and gives me the test alert, but nothing happens when i try to get an alert from SPUtility. ( I also tried using some functions on the form like autocomplete but no luck there as well. Here's the code:

<script language="javascript" type="text/javascript" src="/SiteAssets/jquery-3.2.1.js"></script>
<script language="javascript" type="text/javascript" src="/SiteAssets/jquery.SPServices.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
 alert("jQuery");
alert($().SPServices.SPGetCurrentSite());
});
</script>
Was it helpful?

Solution

FOR USE
jQuery 1.11.x (SPServices 2013.01+) RECOMMENDED
jQuery 1.10.x (SPServices v0.7.2+)
NOT jQuery 1.9.x
Your plugin 'jquery-3.2.1.js' isn't work.

var thisUserAccount = $().SPServices.SPGetCurrentUser({
    fieldName: "Name",
    debug: false
});

If you want to use this SPServices library in a site scope, upload to the “Site Assets” library and import it into master page should be a good practice.

About analyzing your webpage's network traffic in IE Developer Tools:

Analyzing your webpage's network traffic

Also, you can get information from the console of the browser using IE Developer Tools, it will give you more information if there will be any error in this page.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top