I wrote a JavaScript function where I get my Tasks and Tasks from Team Space. They are supposed to look like: enter image description here

And this works as long as its a own HTML-site. Like tasks.html. When I try to add it to another SharePoint-site like home in an content-Editor I get an typeerror:

sp.ui.utility is undefined

and the site stops responding. So my question is why is that so? There is something I don't get.

Here is the Code: HTML:

<div class="due-display" id="dueDisplayVisibility" onclick="winOpen();">
    <p id="loadingText" class="loadIndicator">Loading...  <img src="/Style Library/kcs/images/loader.gif"></p>
    <div class="overDue" id="overDueForm">
                <th class="th-due-digits-red" id="overDueDigits"></th> <!--gets filled by function: fillDueDisplayForms()-->
                <th class="th-due-text-red" id="overDueText"></th> <!--gets filled by function: fillDueDisplayForms()-->
    <div class="dueSoon" id="dueSoonForm">
                <th class="th-due-digits-orange" id="dueSoonDigits"></th> <!--gets filled by function: fillDueDisplayForms()-->
                <th class="th-due-text-orange" id="dueSoonText"></th> <!--gets filled by function: fillDueDisplayForms()-->
    <div class="neverDue" id="neverDueForm">
                <th class="th-due-digits-green" id="neverDueDigits"></th> <!--gets filled by function: fillDueDisplayForms()-->
                <th class="th-due-text-green" id="neverDueText"></th> <!--gets filled by function: fillDueDisplayForms()-->
    <div class="noMySite" id="noMySiteForm">
        <p id="noMySiteTextLine1" class="noMySiteText"></p> <!--gets filled by function: fillNoMySiteForm() -->
        <p id="noMySiteTextLine2" class="noMySiteText"></p> <!--gets filled by function: fillNoMySiteForm() -->

and the JavaScript:

<script src="/_layouts/15/init.js" type="text/javascript"></script>
<script src="/_layouts/15/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.core.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.runtime.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.workmanagement.js" type="text/javascript"></script>
<script src="/Style%20Library/kcs/js/jquery.js"></script>

$(document).ready(function () {

If you want I can post the full java script file.

Any help or advise would be great.

Edit: Just tried it with:

$(document).ready(function() {
 ExecuteOrDelayUntilScriptLoaded(getMyTasks, "sp.js");

and the error stays the same: sp.ui.utility is undefined

Edit2: error was this line:

<script src="/_layouts/15/init.js" type="text/javascript"></script>

real name of the file:

<script src="/_layouts/15/sp.init.js" type="text/javascript"></script>

together with the solution from below it works without any Problems.

  • Please tag your SharePoint version – Amal Hashim Jul 18 '16 at 12:31
  • made an edit sorry – opelhatza Jul 18 '16 at 12:33
  • It seems that your SP.js is not loaded. – Dikesh Gandhi Jul 18 '16 at 12:38
  • Are you trying to put the HTML & JavaScript directly into the Content Editor? – Amal Hashim Jul 18 '16 at 12:38
  • @AmalHashim no with link from the file. – opelhatza Jul 18 '16 at 12:40

Try this for calling your function:


You will get more info from below link:

SP.SOD.executeFunc(key, functionName, fn) Method

| improve this answer | |
  • wont work error stays the same sp.ui.utility is undefined. but at least the Browser no longer crashes. – opelhatza Jul 18 '16 at 12:48
  • Please try this...I've updated my answer – Dikesh Gandhi Jul 18 '16 at 12:54
  • now it works but not fluid it laggs and loads very long. Sadly and as soon as i click somewhere on the site i get an error becouse sp.ui.utility is undefined. – opelhatza Jul 18 '16 at 13:01
  • turns out the error was <script src="/_layouts/15/init.js" type="text/javascript"></script> becouse the real name is sp.init.js and together with your code snippet it works. Thanks – opelhatza Jul 18 '16 at 14:28

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.