This project has moved. For the latest updates, please go here.

Need help on using SPUtility

Feb 1, 2015 at 8:55 AM
Hi guys,

I know this will be a very very stupid question but i hope you bear with me. Im not an advance user in programming so i need your help.

I am using Sharepoint Online/365 and I have a list with different fields. when i uploaded getting started.html it works and shows me that both jquery and SPUtility has been loaded and shows the different fields i have. But when i try to put the code below it doesnt hide the field:
<script src="https://abb.sharepoint.com/sites/InfrastructureandUtilitiesBusiness/Shared%20Documents/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="https://abb.sharepoint.com/sites/InfrastructureandUtilitiesBusiness/Shared%20Documents/sputility.js" type="text/javascript"></script>

<script type="text/javascript">

SPUtility.GetSPField('Project Name').Hide();

</script>
Please help/
Feb 1, 2015 at 9:51 AM
Just to add I get the below error when i access F12> Console:
Uncaught Unable to get a SPField named Project Name
Coordinator
Feb 1, 2015 at 3:23 PM
Great! Sounds like you have everything uploaded OK.

From your code, just looks like you need to wait for the page to load. Try this:
<script src="https://abb.sharepoint.com/sites/InfrastructureandUtilitiesBusiness/Shared%20Documents/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="https://abb.sharepoint.com/sites/InfrastructureandUtilitiesBusiness/Shared%20Documents/sputility.js" type="text/javascript"></script>
<script>
// wait for the window to load
$(window).load(function () {
   // hide the project name field
   SPUtility.GetSPField('Project Name').Hide();
});
</script>
Feb 2, 2015 at 5:17 AM
Damn your good! it worked like a charm! thanks a lot kitmenke! Just want to check should i put the window load syntax everytime? What is it for?
Coordinator
Feb 2, 2015 at 11:52 PM
Edited Feb 2, 2015 at 11:55 PM
$(window).load(..) is jQuery code which waits until the browser has finished loading the page before running your code.

I recommend using $(window).load(..) most of the time but there are some more advanced options for running SPUtility listed at the bottom of the Installation page.
Feb 3, 2015 at 6:09 AM
Hi Kit,

I've been getting some problems again. I hope im not being a nuisance.
  1. My code seems to work with the latest IE11 but doesnt seem to work on IE9 for example. Is this a known issue? or there is a work around to that?
  2. The code below doesnt seem to work. Basically I want to make fields hidden depending on a checkbox status and again make fields read only depending on a drop down menu value.
Please advice and thank you for you support.
<script src=jquery-1.11.2.min.js type="text/javascript"></script>
<script src=sputility.js type="text/javascript"></script>

<script type="text/javascript">
$(window).load(function () {

var revision = SPUtility.GetSPField('Revision Created')
if (revision.GetValue() == 'Yes' ){
    SPUtility.GetSPField('Status').Hide()
}


var status = SPUtility.GetSPField('Status');
if (status.GetValue() == 'In Process') {
    SPUtility.GetSPField('WBS #').MakeReadOnly();
    SPUtility.GetSPField('Project Name').MakeReadOnly();
    SPUtility.GetSPField('Customer Name').MakeReadOnly();
    SPUtility.GetSPField('Remarks').MakeReadOnly();
    SPUtility.GetSPField('Design Engineer').MakeReadOnly();
    SPUtility.GetSPField('Reason for Change').MakeReadOnly();
    SPUtility.GetSPField('Deadline').MakeReadOnly();
    SPUtility.GetSPField('Priority').MakeReadOnly();
}
else {
    SPUtility.GetSPField('WBS #').MakeReadOnly();
    SPUtility.GetSPField('Project Name').MakeReadOnly();
    SPUtility.GetSPField('Customer Name').MakeReadOnly();
    SPUtility.GetSPField('Remarks').MakeReadOnly();
    SPUtility.GetSPField('Design Engineer').MakeReadOnly();
    SPUtility.GetSPField('Reason for Change').MakeReadOnly();
    SPUtility.GetSPField('Deadline').MakeReadOnly();
    SPUtility.GetSPField('Priority').MakeReadOnly();
    SPUtility.GetSPField('Design Engineer Acknowledged').MakeReadOnly();
    SPUtility.GetSPField('Comments').MakeReadOnly();
    SPUtility.GetSPField('Revision Created?').MakeReadOnly();
    SPUtility.GetSPField('Status').MakeReadOnly();
}
});

</script>
Coordinator
Feb 3, 2015 at 5:55 PM
It should work with IE 9 as well. Only thing I notice right away is you are missing a couple semi-colons for your Revision Created field.
<script src=jquery-1.11.2.min.js type="text/javascript"></script>
<script src=sputility.js type="text/javascript"></script>

<script type="text/javascript">
$(window).load(function () {

var revision = SPUtility.GetSPField('Revision Created');
if (revision.GetValue() == 'Yes' ){
    SPUtility.GetSPField('Status').Hide();
}


var status = SPUtility.GetSPField('Status');
if (status.GetValue() == 'In Process') {
    SPUtility.GetSPField('WBS #').MakeReadOnly();
    SPUtility.GetSPField('Project Name').MakeReadOnly();
    SPUtility.GetSPField('Customer Name').MakeReadOnly();
    SPUtility.GetSPField('Remarks').MakeReadOnly();
    SPUtility.GetSPField('Design Engineer').MakeReadOnly();
    SPUtility.GetSPField('Reason for Change').MakeReadOnly();
    SPUtility.GetSPField('Deadline').MakeReadOnly();
    SPUtility.GetSPField('Priority').MakeReadOnly();
}
else {
    SPUtility.GetSPField('WBS #').MakeReadOnly();
    SPUtility.GetSPField('Project Name').MakeReadOnly();
    SPUtility.GetSPField('Customer Name').MakeReadOnly();
    SPUtility.GetSPField('Remarks').MakeReadOnly();
    SPUtility.GetSPField('Design Engineer').MakeReadOnly();
    SPUtility.GetSPField('Reason for Change').MakeReadOnly();
    SPUtility.GetSPField('Deadline').MakeReadOnly();
    SPUtility.GetSPField('Priority').MakeReadOnly();
    SPUtility.GetSPField('Design Engineer Acknowledged').MakeReadOnly();
    SPUtility.GetSPField('Comments').MakeReadOnly();
    SPUtility.GetSPField('Revision Created?').MakeReadOnly();
    SPUtility.GetSPField('Status').MakeReadOnly();
}
});

</script>
Feb 3, 2015 at 6:23 PM
Thans kit! Got it all sorted out works on my machine but it never works on others having IE9 or basically any other browsers other than mine. I dont know what to check :(