5

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>
5

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.

  • I changed it to jquery-1.11.1.min.js and its still not working I'm afraid. – Kloggy Aug 24 '17 at 11:35
  • 1
    What is F12 console, errors? – user37251 Aug 24 '17 at 11:36
  • There is 8 errors and 8 !'s but i thing that one is of importance: SCRIPT5009: '$' is undefined NewForm.aspx (684,1) There is also: Tag cannot be self-closing. Use an explicit closing tag. a couple of times And a couple of SEC7111: HTTPS security is compromised by res://ieframe.dll/forbidframing.htm and other files – Kloggy Aug 24 '17 at 11:43
  • 1
    Okay thanks a lot for help. It turned out that the reference i used was incorrect as my site is a subsite of the site collection and it entered /siteassets of the whole site collection, not my subsite. I found it thanks to the IE traffic tool you showed me. Thanks a lot! – Kloggy Aug 24 '17 at 12:05
  • @Kloggy your welcome :)) – user37251 Aug 24 '17 at 12:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.