Header

Showing posts with label SPAPI with Sharepoint. Show all posts
Showing posts with label SPAPI with Sharepoint. Show all posts

Thursday, 20 September 2012

Find the list item attachment url using SPAPI

Webmasters Earn Money Here!
Find the url of the attachments
-------------------------------------------------
function getattachment(id)
{
 var lists = new SPAPI_Lists('http://yoursite/Announcements');
 var items = lists.getAttachmentCollection("Announcements",id);
 if (items.status == 200){

  var rows = items.responseXML.getElementsByTagName('Attachment');
  if (rows.length>0){
   var str="";
   for (var i=0; i<rows.length; i++){
    alert($(rows[i]).text());
    }
   }
  else
  {
   return  "/Announcements/Lists/Announcements/DispForm.aspx?ID="+id;
  }
 }

}
//Here my site is 'http://yoursite/Announcements' and my list name is "Announcements" and id=ID of the item

know wheather the item has any attachment or not
-------------------------------------------------------------------------
function list_itms(itemid)
{
 var lists = new SPAPI_Lists('http://yoursite/Announcements');
 var items = lists.getListItems('Announcements');
 if (items.status == 200)
  {
  var rows = items.responseXML.getElementsByTagName('z:row'); // Get only list rows
      for (var i=0; i<rows.length; i++)
    {
   if (itemid == ows_ID){
    var newid =rows[i].getAttribute('ows_Attachments');
    alert(newid);
   }
    
  }
 }
}
//The above code is to know wheather the item has any attachment or not
//Here my site is 'http://yoursite/Announcements' and my list name is "Announcements" and id=ID of the item

Saturday, 3 December 2011

Insert data using SPAPI

We need to call this function for adding content in lis..
function Feedbackadd()
   {
            var regad_var = $("#regad1 option:selected").text();
            \\ Get the value from one DropDown list that id is regad1
            var sub_var = $("#sub1").attr('value'); 
           \\ Get the value from one text box that id is sub1.
            var name_var = $("#name1").attr('value');
            \\ Get the value from one text box that id is name1.
            var email_var = $("#email1").attr('value');
            \\ Get the value from one text box that id is email1.
            var msg_var = $('#textareamsg1').val();
             \\ Get the value from one text box that id is textareamsg1.
            var lists = new SPAPI_Lists('listLocationt');
            \\ Give the location of document where Feedback list is there.
            var res = lists.quickAddListItem('Feedback', { Title:sub_var, Regarding:regad_var, Subject:sub_var, Name:name_var, Email:email_var, Message:msg_var });
      
         if (res.status == 200)
            {
                alert('Thank you for Feedback.');
              }
            else
            {
                alert('Unexpected error.');
            }
          
        }


Thanks ....................:-) 

Thursday, 20 October 2011

Hot to get Current user name using SPAPI

 This post has been moved to this

http://unique2026.blogspot.in/2013/08/hot-to-get-current-user-name-using-spapi.html


How to start with SPAPI in Sharepoint

 This post has moved to this link.

http://unique2026.blogspot.in/2013/08/how-to-start-with-spapi-in-sharepoint.html