Posts

SharePoint 2013 "_spUserId" is undefined

_ spUserId is deprecated in SP2013. Use _ spPageContextInfo.userId instead.

SharePoint List : Check if the user has attached file

​​<script type="text/javascript" language="javascript"> function PreSaveAction() {     var attRow = document.getElementById("idAttachmentsTable");     if (attRow == null || attRow.rows.length == 0) { document.getElementById("idAttachmentsRow").style.display='none'; alert("Please attach the file. Attachment is mandatory"); return false ; } else { return true ;} } </script>​

SharePoint Form Digest

Form Digest Form Digest is used to insert a security validation for SharePoint pages. The digest value will be created by SharePoint server during page creation. Example:  A user loads a SharePoint page. He injected a script which updates the list data. When the user posts the page, the server will check Form Digest value against the page content. Thus, security attacks can be prevented. Viewing Form Digest You can use the view-source of a SharePoint page to see the form digest value. The value is stored under name  ___REQUESTDIGEST .

Read Document Library Items

 $().SPServices({     operation: "GetListItems",     async: false,     listName: "DOCUMENT LIBRARY",     CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='EncodedAbsUrl'/></ViewFields>",     completefunc: function (xData, Status) {       $(xData.responseXML).SPFilterNode("z:row").each(function() {         var doc = "<li><a href="+$(this).attr("ows_EncodedAbsUrl")+">" + $(this).attr("ows_Title") + "</a></li>";         $("#divTag").append(doc);       });     }   });

Retrieve SharePoint List Item Attachments using SPServices

$().SPServices({         operation: "GetAttachmentCollection",         async: false,         listName: "LIST NAME",         ID: ItemID,         completefunc: function(xData, Status) {             var attachments = [];               $(xData.responseXML).find("Attachment").each(function() {                var url = $(this).text();                attachments.push(url);             });                     }    });

SharePoint List Operations on SharePoint 2013 using REST API Services In - Part IV (GET All Items)

function GetItems() {       $.ajax     ({         url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('SharePoint List Name')/items?$select=Column1,Column2",         type: type,         data: data,         headers:         {             "Accept": "application/json;odata=verbose",             "Content-Type": "application/json;odata=verbose",             "X-RequestDigest": $("#__REQUESTDIGEST").val(),             "IF-MATCH": "*",             "X-HTTP-Method": null         },         cache: false,         success: function(data)           {     //success - bind values here     ...

SharePoint List Operations on SharePoint 2013 using REST API Services In - Part III (DELETE)

function deleteItemByID(id) {     $.ajax     ({         url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('SharePoint List Name')/items("+id+")",         type: "POST",         headers:         {             "X-RequestDigest": $("#__REQUESTDIGEST").val(),             "IF-MATCH": "*",             "X-HTTP-Method": "DELETE"         },         success: function(data, status, xhr)         {             //alert("Success");         },         error: function(xhr, status, error)         {            //Failure         }     }); }