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

Wednesday, July 29, 2015

https://msdn.microsoft.com/en-us/library/ff398052(v=vs.120).aspx

Saturday, July 18, 2015

Write CSOM/JSOM/REST call in ASPX page

Nice Blog : http://allthatjs.com/2012/04/03/using-sharepoint-csom-in-html5-apps/
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<%@ Page language="C#" %>
<%@ Register Tagprefix="SharePoint" 
     Namespace="Microsoft.SharePoint.WebControls" 
     Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<html>
<head>
      <title></title>
    <!-- the following 5 js files are required to use CSOM -->
     <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
    <script type="text/javascript"src="/_layouts/1033/init.js"></script>
    <script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.core.js"></script>
    <script type="text/javascript" src="/_layouts/15/SP.Runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/SP.js"></script>
 
    <!-- include your app code -->
       <script type="text/javascript">

           var context = SP.ClientContext.get_current();
           var user = context.get_web().get_currentUser();

           // This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
           $(document).ready(function () {
               getUserName();
           });

           // This function prepares, loads, and then executes a SharePoint query to get the current users information
           function getUserName() {
               context.load(user);
               context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
           }

           // This function is executed if the above call is successful
           // It replaces the contents of the 'message' element with the user name
           function onGetUserNameSuccess() {
               $('#message').text('Hello ' + user.get_title());
           }

           // This function is executed if the above call fails
           function onGetUserNameFail(sender, args) {
               alert('Failed to get user name. Error:' + args.get_message());
           }

    </script>

-->
  
</head>
<body>
    <SharePoint:FormDigest ID="FormDigest1" runat="server"></SharePoint:FormDigest>

     <div>
        <p id="message">
            <!-- The following content will be replaced with the user name when you run the app - see App.js -->
            initializing...
        </p>
    </div>
</body>
</html>

Wednesday, July 15, 2015

change the site to open the files as permissive

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Add-PSSnapin Microsoft.SharePoint.Powershell
$site = Get-SPSite("http://san001/sites/Harry")
$web = $site.OpenWeb()
$list = $web.GetList("http://san001/sites/Test/Shared Documents")
$list.browserfilehandling                      

$list.browserfilehandling = "Permissive"
$list.update()                                             
$list.browserfilehandling                     

One example is to loop through one web.


Add-PSSnapin Microsoft.SharePoint.Powershell
$site = Get-SPSite("http://san001/sites/Test")
$web = $site.OpenWeb()
foreach ($list in $web.Lists) 
{ 
     if($list.browserfilehandling -eq "Strict") 
     { 
          $list.browserfilehandling = "Permissive"; 
          $list.update(); $site.url, $list.title, $list.browserfilehandling
     } 
}

Tuesday, June 23, 2015

HTML

Script:

JS