Sunday, April 3, 2016

Read the sharepoint 2013 list data using REST and render into Table

var urllink="https://stagetest.com";
var username="";

var listItemInfoAdmin1 ="";
var listItemInfoAdmin2 ="";
var listItemInfoCOS ="";

$(document).ready(function () {
   username = $("#peoplepickerID").text();
   //alert(username);
   AdminSupportStaff1();
   AdminSupportStaff2();
   ChiefOfSupportStaff();
   

    });

function AdminSupportStaff1() {
    $.ajax({
        url: urllink + "/sites/DL/LD/_api/web/lists/getbytitle('People')/items?$filter=AdminSupportStaff eq '" + username + "'",        
        type: "GET",
        headers: { "Accept": "application/json;odata=verbose" },
        cache: false,
        success: function (data) {

               $.each(data.d.results, function (key, value) {
                               
                               listItemInfoAdmin1 +="<tr><td>"+value.First_x0020_Name+" "+value.Last_x0020_Name+"</td><td>Admin</td></tr>";
                               
        
        });  
         $('#tableSupport').append(listItemInfoAdmin1);     
        //$("#countmein").html(listItemInfo);  
  
        },
        error: function (data) {
            //myApp.hidePleaseWait();
                              //            DisplayErrorMessage(errorMsg);
                                             alert("Error");
        }

    });
}


function AdminSupportStaff2() {
    $.ajax({
        url: urllink + "/sites/DL/LD/_api/web/lists/getbytitle('People')/items?$filter=AdminSuppoprtStaff2 eq '" + username + "'",          
        type: "GET",
        headers: { "Accept": "application/json;odata=verbose" },
        cache: false,
        success: function (data) {

               $.each(data.d.results, function (key, value) {
                               
                               listItemInfoAdmin2 +="<tr><td>"+value.First_x0020_Name+" "+value.Last_x0020_Name+"</td><td>Admin</td></tr>";
                               
        
        });  
         $('#tableSupport').append(listItemInfoAdmin2);     
        //$("#countmein").html(listItemInfo);  
  
        },
        error: function (data) {
            //myApp.hidePleaseWait();
                              //            DisplayErrorMessage(errorMsg);
                                             alert("Error");
        }

    });
}

function ChiefOfSupportStaff() {
    $.ajax({
        url: urllink + "/sites/DL/LD/_api/web/lists/getbytitle('People')/items?$filter=ChiefOfSupportStaff eq '" + username + "'",          
        type: "GET",
        headers: { "Accept": "application/json;odata=verbose" },
        cache: false,
        success: function (data) {

               $.each(data.d.results, function (key, value) {
                               
                               listItemInfoCOS +="<tr><td>"+value.First_x0020_Name+" "+value.Last_x0020_Name+"</td><td>Chief of staff</td></tr>";
                               
        
        });  
         $('#tableSupport').append(listItemInfoCOS);     
        //$("#countmein").html(listItemInfo);  
  
        },
        error: function (data) {
            //myApp.hidePleaseWait();
                              //            DisplayErrorMessage(errorMsg);
                                             alert("Error");
        }

    });
}

Monday, March 21, 2016

How to use XSLT for SharePoint listview



1) Create list with column "First Name" and "Last Name"
2) Create XSLT file with below XSLT tags and upload this to pages library.


<xsl:stylesheet version="1.0"

              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

              xmlns:msxsl="urn:schemas-microsoft-com:xslt"

              exclude-result-prefixes="msxsl" xmlns:ddwrt2="urn:frontpage:internal">



  <xsl:output method='html' indent='yes'/>



  <xsl:template match='dsQueryResponse'>
<style>

.LD{
    border-collapse: collapse;
    width: 100%;
}
.LD table, .LD td, .LD th {    
    border: 1px solid #ddd;
    text-align: left;
    width: 25%;

}


.LS th, .LS td {
    padding: 10px;
}

.LS{
    border-collapse: collapse;
    width: 100%;
}
.LS table, .LS td, .LS th {    
    border: 1px solid #ddd;
    text-align: left;
    width: 25%;

}


.LS th, .LS td {
    padding: 15px;
}

</style>

    <table class="LD"  >    

     <xsl:apply-templates select='Rows/Row'/>

    </table>

  </xsl:template>



  <xsl:template match='Row'>


<tr style="background-color:#e9e9e9;">

        <td style="border-width: 0px;">

            <b style="font-size:25px;padding-right:10px"><xsl:value-of select="@First_x0020_Name"></xsl:value-of> </b>
             <b style="font-size:25px"><xsl:value-of select="@Last_x0020_Name"></xsl:value-of> </b>

        </td>
 
 </tr >



 
  </xsl:template>

</xsl:stylesheet>
3) Insert a List view webpart for people list, change the properties of XSLT url with the correct url.

4) Save and check the page.

Wednesday, November 18, 2015

How to use Iframe under SharePoint

I have a sharepoint site : ABC.com\index.aspx this needs to show the content of another SharePoint site DEF.com\Index.aspx Changes need to be done in the Master page of DEF.com site Add the below tag in the head part of the MP.
 <WebPartPages:AllowFraming ID="AllowFraming" runat="server" __WebPartId="{E5EA0CB9-8180-485C-985F-51B4DEB34CC4}" />

Friday, November 13, 2015

Find current login user in sharepoint users group using REST and render output as HTML


$(document).ready(function ()  
{ 
 getCurrentUser(); 
 
}); 
 
function getCurrentUser()   
{  
 $.ajax
 ({  
  url: url+"/_api/web/CurrentUser",  
  method: "GET",  
  headers: { "Accept": "application/json; odata=verbose" },  
  success: function (data)  
  {  
   getCurrentUserGroupColl(data.d.Id);  
  },  
  error: function (data)   
  {  
   failure(data);  
  }  
 });  
}
  
function getCurrentUserGroupColl(UserID)   
{  
 $.ajax  
  ({  
   url: url+"/_api/web/GetUserById(" + UserID + ")/Groups",  
   method: "GET",  
   headers: { "Accept": "application/json; odata=verbose" },  
   success: function (data) 
   {  
   /* get all group's title of current user. */  
   var results = data.d.results; 
   var InnrHtmlgrp = "<br />
<ul>";  
   
   for (var i = 0; i &lt; results.length; i++)   
   {  
    if(results[i].Title == 'owner')
    {
    // Do the changes 
    //InnrHtmlgrp += "
<li>" + results[i].Title + "</li>
";  
    $("#manager").append(managerstring);  
    
    }
   }  
  
    
   }  
  });  
}

Monday, August 3, 2015

Handling Concurrency for the List

http://blogs.technet.com/b/stefan_gossner/archive/2011/11/10/using-synchronous-quot-after-quot-events-e-g-itemupdated-in-sharepoint-2010.aspx http://sharepoint.stackexchange.com/questions/25542/what-happens-if-an-earlier-event-receiver-throws-an-error https://karinebosch.wordpress.com/walkthroughs/event-receivers-walkthrough2/ http://sppms.blogspot.in/2012/05/sharepoint-2010-event-receivers-and.html http://www.sharepoint-tips.com/2012/01/importance-of-synchronous-event.html

Sunday, August 2, 2015

change the colour of sharepoint list item

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js" type="text/javascript"></script>


    $(window).load(function () {
        $Text = $("td.ms-cellstyle.ms-vb2:contains('GREEN')"); 
        $Text.parent().css("fore-color", "#01DF3A");
        $Text.css("color", "#01DF3A");
        $Text = $("td.ms-cellstyle.ms-vb2:contains('RED')");
        $Text.css("color", "#F90101");
        $Text = $("td.ms-cellstyle.ms-vb2:contains('AMBER')");
        $Text.css("color", "#EAC117");
    });
});
http://mekalikot.blogspot.in/2014/07/highlight-row-change-font-color-and.html

HTML

Script:

JS