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

New Post: Set/Change Column(s) value on new form based on Lookup Column

$
0
0
Alright, I managed to get it working using GetListItems function. Below is the code I used.
<script type="text/javascript" src="../../Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.SPServices-2013.02ALPHA3.js"></script>



<script type="text/javascript">

$(document).ready(function() {

$("select[title='Customer']").change(function () {

var CustomerID = $("select[title='Customer']").val();

  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "{DA112625-44A8-453F-B5D6-A7F5B0531D6E}",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Customer_x0020_Contact' /><FieldRef Name='Contact_x0020_Phone' /><FieldRef Name='Contact_x0020_E_x002d_Mail' /><FieldRef Name='Address' /></ViewFields>",

    CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + CustomerID + "</Value></Eq></Where></Query>",

    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var CustomerName = $(this).attr("ows_Title");
        var CustomerContact = $(this).attr("ows_Customer_x0020_Contact");
        var CustomerPhone = $(this).attr("ows_Contact_x0020_Phone");
        var CustomerEMail = $(this).attr("ows_Contact_x0020_E_x002d_Mail");
        var CustomerAddress = $(this).attr("ows_Address");
        $("input[title='Customer Contact']").val(CustomerContact);
        $("input[title='Contact Phone']").val(CustomerPhone);
        $("input[title='Contact E-Mail']").val(CustomerEMail);
        $("textarea[title='Delivery Address']").val(CustomerAddress);
         if (CustomerAddress == undefined)
            {
            var liHtml = "<Strong><li>The address details were not found in the system!!</li></Strong>";
            $("#tasksUL").empty().append(liHtml);
            }
         else
            {
            $("#tasksUL").empty();
            }
      });
    }
  });


});

});


</script>
<ul id="tasksUL"/>

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>