Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Auto population?

$
0
0
Hello again SP Services Folks,

It took me a while to find away to accomplish this functionality but thanks to the you guys and a few blogs found by google, I manage to figure out a way to get the Functionality I wanted to implement. (Learning about DOM helped me understood a lot of the codes that looked foreign to me at first)

The functionality I used was GetListItems as suggested by Mark. At first I didn't understand how to configure it but thanks to some folks posting their questions as well as the codes they used and the corrected versions of the codes but taking what their working codes and building from it helped me collect fragments of knowledge that would later influence me on this simple code.
<script language="javascript" type="text/javascript" src="Mysite/JQueryLibraries/jquery-1.7.2.min.js"></script> 
<script language="javascript" type="text/javascript" src="MySite/JQueryLibraries/jquery.SPServices-2013.01.min.js"></script>
<script language="javascript" type="text/javascript" src="MySite/jQuery%20Libraries/jquery.SPServices-0.5.4.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() 
      {
      // Title will be later changed to EE number
     $("input[title=Title]").change(function() 
        {
        StatusChange();
        });
      });

function StatusChange()
       {
       var thisVal =  $("input[title=Title]").val();
       //The title is stored on a variable to be used on the query string formula below
       var query = "<Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" +  thisVal +"</Value></Eq></Where></Query>"
       $().SPServices({
           operation: "GetListItems",
           async: false,
           listName: "EmployeeList",
           webURL: "http://teams2.corpnt.analog.com/sites/Connections_HR_Services/Test%20Page",
           CAMLQuery: query,
           CAMLViewFields: "<ViewFields><FieldRef Name='EmployeeName' /><FieldRef Name='DataX' /></ViewFields>",    
           completefunc: function (xData, Status) {
                $(xData.responseXML).SPFilterNode("z:row").each(function() 
                    {
                    $("input[title='Employee Name']").val($(this).attr("ows_EmployeeName"));
                    $("input[title=Data2]").val($(this).attr("ows_DataX"));
                    });
                }
            });
            }
</script>
I tried using AutoComplete functionality but it doesn't seem to have completefunc options according to its documentation. Also when I used the SpAutoComplete functionality the event listener doesn't seem to capture the change that occurs on "Title" Field anymore.

I'm ok with the current functionality but being able to get the AutoComplete Function to work alongside the GetListItem call might make this small project from good to great.

Thanks again to all you Folks and once again any advice and guidance will be appreciated.

Francis

Viewing all articles
Browse latest Browse all 6517

Trending Articles