SPUtility not working correctly
-
08-10-2020 - |
Question
I just started using this tool, so I tested SetValue
in order to familiarize myself with it. It seemed to only work whenever I hit the "Ok" button to the Content Editor web part of the new/edit form. Whenever I actually tried to create/edit a form, I was met with blank fields. Could someone let me know what I could be missing?
Here's my code:
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="/MySite/SiteAssets/Code/SPUtility/sputility.min.js"></script>
<script>
// wait for the window to load
$(document).ready(function () {
// EXAMPLE: Set the value of the Title field to Hello world!
SPUtility.GetSPField('Title').SetValue('Hello world!');
SPUtility.GetSPField('Occurrence No.').SetValue('25');
});
</script>
Solution
I once ran into a problem where my script was not executing because I forgot the "type" attribute in the script tag. Try changing your opening script tag to
<script type="text/javascript">
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange