.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Create Sharepoint Custom List using SharePoint web service in JavaScript

Posted By:Sagar Pardeshi       Posted Date: November 03, 2013    Points: 40    Category:    URL: http://www.dotnetspark.com  

Create Custom List in SharePoint at Client side using JavaScript
 

<script type="text/javascript">
function GetRootUrl() {    
    var urlParts = document.location.href.split('/');
    var serverurl = urlParts[0] + '//' + urlParts[2];
    return serverurl;
}

function getCountry()
{
debugger;
    var listName = 'Country';
    var arr = new Array();
    var a = new ActiveXObject("Microsoft.XMLHTTP");

    if (a == null) return null;

    var getListRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
    + "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
    + "<soap:Body>"
    + "<AddList xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">"
    + "<listName> "+listName +"</listName>"
    + "<description>TestGenricList</description>"
    + "<templateID>100</templateID>"
    + "</AddList>"
    + "</soap:Body>"
    + "</soap:Envelope>";

    a.Open("Post",GetRootUrl()+ "/_vti_bin/Lists.asmx?op=AddList", false);
    a.setRequestHeader("Content-Type:", "text/xml; charset=utf-8");
    a.setRequestHeader("SOAPAction:", "http://schemas.microsoft.com/sharepoint/soap/AddList");
    a.Send(getListRequest);

    var xmlDoc = a.responseXML;
    }
</script>

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend