Sharepoint Ajax List Data populater Example


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function btnSubmitEntry_OnClick() {
  2. $('#contentLoading').show();
  3. var ourProperty = EscapeHtmlString($('#selProperty :selected').text());
  4. var ourAffectedUrl = EscapeHtmlString($('#selUrl :selected').text());
  5. var ourStagingUrl;
  6.  
  7. if (ourAffectedUrl.indexOf('/') == 0) {
  8. if (ourProperty.indexOf('MS.com') > -1) ourStagingUrl = "http://wwwstaging" + ourAffectedUrl;
  9. else if (ourProperty.indexOf('http://') > -1) ourStagingUrl = "http://standards" + ourAffectedUrl;
  10. else ourStagingUrl ="n/a";
  11. }
  12. else if ((ourAffectedUrl == "new page") || (ourProperty == "talkstandards.com")) ourStagingUrl ="to be determined" ;
  13. else ourStagingUrl ="n/a" ;
  14.  
  15. var updateString = "<Batch OnError=\"Continue\">";
  16. updateString += "<Method ID=\"1\" Cmd=\"New\">";
  17. updateString += "<Field Name=\"ID\">1</Field>";
  18. //updateString += "<Field Name=\"Title\">" + EscapeHtmlString($("#txtTitle").val()) + "</Field>";
  19. updateString += "<Field Name=\"Title\">Bug or Change Request </Field>";
  20. updateString += "<Field Name=\"Property\">" + ourProperty + "</Field>";
  21. updateString += "<Field Name=\"Property_x0020_Owner\">" + getPropertyOwner($('#selProperty :selected').text()) + "</Field>";
  22. updateString += "<Field Name=\"URL_x0020_Affected\">" + ourAffectedUrl + "</Field>";
  23. updateString += "<Field Name=\"The_x0020_Requester\">" + EscapeHtmlString($("#txtAuthor").val()) + "</Field>";
  24. updateString += "<Field Name=\"staging_x0020_url\">" + ourStagingUrl + "</Field>";
  25. updateString += "<Field Name=\"Description\">" + EscapeHtmlString($("#txtDescript").val()) + "</Field>";
  26. updateString += "<Field Name=\"Priority_x0020_Level\">" + EscapeHtmlString($('#selPriority :selected').text()) + "</Field>";
  27. updateString += "<Field Name=\"Type_x0020_of_x0020_Request\">" + EscapeHtmlString($('#selType :selected').text()) + "</Field>";
  28. updateString += "<Field Name=\"Go_x0020_Live_x0020_Date\">" + EscapeHtmlString($("#txtGoLiveDate").val()) + "</Field>";
  29. updateString += "<Field Name=\"Go_x0020_Live_x0020_Time\">" + EscapeHtmlString($("#txtGoLiveTime").val()) + "</Field>";
  30. updateString += "<Field Name=\"PageSection\">" + EscapeHtmlString($("#txtSection").val()) + "</Field>";
  31.  
  32.  
  33.  
  34.  
  35.  
  36. updateString += "</Method>";
  37. updateString += "</Batch>";
  38. try {
  39. UpdateListItems("Change Requests", updateString, callback_Submit); }
  40. catch (err) {
  41.  
  42. alert(err.message);
  43.  
  44. }
  45. }
  46.  
  47.  
  48. function callback_Submit(respObj, status) {
  49. var soapError = SoapErrorCheck(respObj);
  50. if (soapError.length == 0) {
  51. if (respObj.xml.length > 0) {
  52. var rows = $("z\\:row", respObj);
  53. requestID = trim($(rows[0]).attr("ows_ID"))
  54.  
  55. var editUrl = $("a#attachLink").attr("href") + "?ID=" + requestID;
  56. var attachmentUrl = $("a#custom-popup").attr("href") + "?ID=" + requestID;
  57.  
  58. $("a#attachLink").attr("href", editUrl );
  59.  
  60. $("a#custom-popup").attr("href", attachmentUrl );
  61.  
  62. $('#submittalConfirmation').show();
  63. $('#requestForm').hide();
  64. $('#contentLoading').hide();
  65. }
  66. else {
  67. alert("Error updating request list. Try again and if the error continues please contact your administrator.");
  68. }
  69. }
  70. else {
  71. alert("Error submitting your request: \n" + soapError);
  72. }
  73. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.