title: Create and list new Sharepoint page template with jquery and SPservices
body: <p>I'm building a medical wiki on Sharepoint Foundation 2013 that'll make it possible to (1) create new wiki pages from a template and (2) add the titles and urls of those new pages to a custom list.</p>
  
  <p>The following code takes care of number (1). Users input a newname for the new wiki page, click 'create dossier' and the template page is copied and renamed newname.aspx. </p>
  
  <pre><code>&lt;hr/&gt;
  &lt;p&gt;To create a new dossier, type the child’s name then press the 
  &lt;em&gt;Create dossier&lt;/em&gt; button below.&lt;/p&gt;
  
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"&gt;
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function myCreateProject() 
  {
  
  var PATHTOWIKI = "/medical";
  var PATHTOPAGES = "Medical Dossiers";
  var TEMPLATEFILENAME = "template";
  
  var myPathToWiki = encodeURIComponent(PATHTOWIKI);
  var myPathToPages = PATHTOPAGES + "%2f";
  var myTemplateFileName = encodeURIComponent(TEMPLATEFILENAME) + "%2easpx";
  
  var EnteredProject = document.getElementById("NewProjName");
  var myNewName = EnteredProject.value;
  
  if(myNewName == "")
  {
  alert('Please enter a name for the new dossier'); 
  }
  else
  {
  myNewName = encodeURIComponent(myNewName) + "%2easpx"
  $.ajax({
  url: PATHTOWIKI + "/_vti_bin/_vti_aut/author.dll",
  data: ( "method=move+document%3a14%2e0%2e0%2e4730&amp;service%5fname="
   + myPathToWiki +
  "&amp;oldUrl=" + myPathToPages + myTemplateFileName +
  "&amp;newUrl=" + myPathToPages + myNewName +
  "&amp;url%5flist=%5b%5d&amp;rename%5foption=nochangeall&amp;put%5foption=edit&amp;docopy=true"
   ),
  success: function(data)
  {
  var rpcmsg1 = getMessage(data, "message=", "&lt;p&gt;");
  $("#myInfo").append("&lt;br/&gt;" + rpcmsg1);
  if(rpcmsg1.indexOf("successfully") &lt; 0)
  {
  // get error info
  var rpcmsg2 = getMessage(data, "msg=", "&lt;li&gt;");
  $("#myInfo").append("&lt;br/&gt;" + rpcmsg2 + "&lt;br/&gt;");
  }
  else
  {
  $("#myInfo").append("&lt;br/&gt;&lt;a href=\"http://it.bethelchina.org/" + PATHTOWIKI + "/" + PATHTOPAGES + 
  "/" + myNewName + "\"&gt;Go to new page&lt;/a&gt;&lt;br/&gt;");
  }
  
  }, 
  type: "POST",
  beforeSend: function(XMLHttpRequest)
  {
  XMLHttpRequest.setRequestHeader("X-Vermeer-Content-Type", 
  "application/x-www-form-urlencoded");
  }
  }); 
  
  }
  
  }
  
  function getMessage(data, startmsg, delim)
  {
  
  var msgpos = data.indexOf(startmsg);
  var endpos = data.indexOf(delim, msgpos);
  var rpcmsg = data.substring(msgpos + startmsg.length, endpos);
  return rpcmsg;
  
  }
  &lt;/script&gt;
  &lt;input id="NewProjName" type="text"/&gt; &lt;input id="AutoButton" 
  onclick="myCreateProject();" type="button" value="Create dossier"/&gt; &lt;br/&gt;
  &lt;div id="myInfo"&gt;&lt;b&gt;Results&lt;/b&gt;&lt;br/&gt;&lt;/div&gt;
  </code></pre>
  
  <p>What I can't figure out is how to add the URL of the new dossier/page and it's corresponding myNewName to a custom list. I know that SPservice and UpdateListItems will have to come into play but I'm having no luck coding it into the jquery above. </p>
  
  <p>Help would be much appreciated,</p>
  
  <p>Regards,</p>
  
  <p>Matt</p>