jquery script not working on SPF 2013

Jun 29, 2016 at 1:30 PM
Hi All,

I have created one SP list on Foundation 2013 with 5 cascading lookup fields using the Advanced Lookup utility (available in Codeplex). The form is working fine but when I add the script found to auto populate the Department field (this is the only Text field) in the form it doesn't fetch any data.

I have put the Jquery-3.0.0.min.js, jquery.SPServices-2014.02.min.js and the script below (AutoFill.js) in the Scripts folder under Style Library.

On the form page I added a Content Editor Web part with the path to the script AutoFill.js. Any help will be appreciated.

The script is

<script language="javascript" type="text/javascript" src="/sites/test/style%20library/scripts/jquery-3.0.0.min.js"></script>
<script language="javascript" type="text/javascript" src="/sites/test/style%20library/scripts/jquery.SPServices-2014.02.min.js"></script>
<script language="javascript" type="text/javascript"> $(document).ready(function() { var userDepartment = $().SPServices.SPGetCurrentUser({ fieldName: "Department" }); $("input[Title='Department']").val(userDepartment); }); </script>
Jun 30, 2016 at 1:57 AM

It appears that the HTML code may be the culprit. When creating the input text box, give it a unique id, and then reference the id in your javascript code. When referencing the input in your javascript code, precede the id of the input with #. Below is an example:

HTML code

<input id="department" type="text">

Javascript code


var userDepartment = $().SPServices.SPGetCurrentUser({ fieldName: "Department");


As a note, if you're using HTML5, then you don't need to insert type="text/javascript" in your script tag. You also don't need to specify the language. The title attribute is usually used when you want to provide a tooltip for an html element.