Create Sharepoint Custom List : Web Services (JavaScript)

Posted: November 7, 2014 in SharePoint2010, SharePoint2013

CreateCustom List in SharePoint using JavaScript with SharePoint web service.

Code Steps

<script type=”text/javascript”>

function GetRootUrl() {

var urlParts = document.location.href.split(‘/’);

var serverurl = urlParts[0] + ‘//’ + urlParts[2];

return serverurl;


function CreateListCountry() {

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=\”\” xmlns:xsd=\”\” xmlns:soap=\”\”>”+ “<soap:Body>” + “<AddList xmlns=\”\”>” + “<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:”, “;);


var xmlDoc = a.responseXML;




<input type”button” onclick=”javascript:CreateListCountry();” Text=”Create List”/>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s