1

I'm using SharePoint 2013. I need to fetch data from another list and insert it in my new form(Custom form). But after fetching data from another list and setting all values, when i click on save it gives SharePoint WebPart error and only WebPart ID is given.

I don't know why this error is coming and how to solve it? Even i tried SPServices to fetch information but it gives 500(internal server error.)

   $().SPServices({ 
operation: "GetListItems", 
async: false, 
listName: "Requests", 
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Application' /></ViewFields>", 
CAMLQuery: "<Query><Where></Where></Query>", 
completefunc: function (xData, Status) 
{ $(xData.responseXML).SPFilterNode("z:row").each(function() 
{ var req = $(this).attr("ows_Application"); $("select[Title='Request']").append(new Option(req,req)); }); 
} 
});
  • please paste your code what you are trying.. – Siddharth Vaghasia Dec 6 '16 at 7:00
  • $().SPServices({ operation: "GetListItems", async: false, listName: "Requests", CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Application' /></ViewFields>", CAMLQuery: "<Query><Where></Where></Query>", completefunc: function (xData, Status) { $(xData.responseXML).SPFilterNode("z:row").each(function() { var req = $(this).attr("ows_Application"); $("select[Title='Request']").append(new Option(req,req)); }); } }); – Tushar Chaudhari Dec 6 '16 at 7:51
  • I changed my CDN and now List.asmx file is properly loaded, but Now its not detecting z:row. – Tushar Chaudhari Dec 6 '16 at 7:53
  • please update you code in question in formatted version... – Siddharth Vaghasia Dec 6 '16 at 9:03
  • 1
    Programmers don't use alert, learn to use the DEV console and trace your code: msdn.microsoft.com/en-us/library/gg589530(v=vs.85).aspx – Danny '365CSI' Engelman Dec 6 '16 at 10:00
0

You can use below code to perform the same operation. Code below uses rest api to fetch the data from the list and perform the same action which you are trying to do using SPServices.

$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Requests')/items?$select=Title,Application",
contentType: "application/json;odata=verbose",
headers: {
    "accept": "application/json;odata=verbose"
},
success: function(data) {
    $.each(data.d.results, function(index, value) {
        $("select[Title='Request']").append(new Option(value["Application"], value["Application"]));
    });
},
error: function(data) {
    alert("Request Failed");
    console.log(data)
}
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.