Posts

Showing posts with the label SharePoint

SharePoint JSOM Nested Include Properties

Hi All, Sometimes we need to get properties which are nested inside of Listitem and we wonder will it be feasible to make multiple queries for the same. So this scenarios usually occurs when you have to get a set of listitems which are folder and we need to get folder properties of the folder. So you can query it using below method. Just add the sub properties in Include tag

Get Workflow History using Workflow.asmx SharePoint 2010

Sometimes we need to display workflow history based on the item id of the list item.

SharePoint 2010 List View Header Count of Rows

Hi All, Sometimes we need to show the number of rows in the header itself when we have created an accordion on the webpart header.below is the code which helps us display count of the rows. $(".s4-wpTopTable").each(function(){ var countOfRows=   $(this).find(".ms-listviewtable").find("tr .ms-vb2:first-child").length;   $(this).find(".ms-WPTitle a span:first-child").append("<b> (" + countOfRows + ")</b>"); }) ; Edit: ID column is needed in the list view to display the count.Working on it so that this can be eliminated.

SharePoint Ribbon Customisation

Below are the two reference of SharePoint ribbon customisation which i found interesting. http://www.umtsoftware.com/blog/creating-sharepoint-ribbon-elements-in-javascript/ http://spevilgenius.blogspot.in/2013/10/creating-ribbon-tabs-and-buttons-in.html

OOTB Export to Excel using JSOM SharePoint 2010

Well sometimes we think that we could leverage OOTB Export to Excel option in our custom pages. With below JSOM code we can

Quick rename List View group by collapisble label without changing the value of the column SharePoint 2010 Javascript

Now this is a quick fix when many a times we need to display the label of collapsible group name something different that the actual column value.Below is a script which will just allow you to do that  $("tr[id^='group'] td").each(function(){   var text = $(this).html();         $(this).html(text.replace('Save as Draft','Draft')); });

Make webparts header as collapsible accordion SharePoint 2010 Javascript

Sometimes when there are lots of web parts on the page we wish that all the web parts be accordion, we can make them accordion using below script. Now in this case i have restricted this script to run on specific page as i had implemented it in master page. $(document).ready(function(){   if(window.location.href.indexOf("DEF") > -1 || window.location.href.indexOf("ABC") > -1) {           $(".ms-WPHeader").parent().parent().parent().parent().parent().find(".ms-wpContentDivSpace").toggle();      $(".ms-WPHeader").click(function(){ $(this).parent().parent().parent().parent().parent().find(".ms-wpContentDivSpace").toggle(); return false; }); } });

Check if user exists in SharePoint 2010 Group JSOM JavaScript

When we need to check whether the user exists in a group using JSOM we can use the below function. This function takes group id as parameter which can be easily extracted from the group url.The second parameter is success function which is a callback.The usage is described below the function function isCurrentUserMemberOfGroup(groupId, OnComplete) {         var context = SP.ClientContext.get_current();         var currentUser = context.get_web().get_currentUser();         context.load(currentUser);         var group = context.get_web().get_siteGroups().getById(groupId);         context.load(group,'Users');         context.executeQueryAsync(OnSuccess,OnFailure);         function OnSuccess(sender, args) {             var userInGroup = false;             var e = group.get_users...

SharePoint Posts Ratings Migration

Hi All, Recently our team had a requirement to migrate ratings.Below is a sample code to add ratings to ratings for an item. public void AddPostItem( LRBlog blog, SiteMigrationConfiguration siteMigrationConfiguration)         {             try             {                 Console .WriteLine( DateTime .Now.ToShortTimeString() + "Adding blog post, post id :" );                 List list = clientContext.Web.Lists.GetByTitle(siteMigrationConfiguration.BlogPostListName);                 ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation ();      ...

SharePoint Concoct

Hi All, SharePoint Concoct is framework for SharePoint Portals.Now since the vision is to build a robust and reusable framework it may take some time to come up with an alpha release to. Currently the framework is in showcase which can be browsed here  SharePoint Concoct . Your feedback is always necessary for any open source projects to become stable. Current Showcase release consist of 1. Framework 2. Jquery Plugin Files 3.  Connectors 4. Caml Helpers 5. Powershell Scripts Will keep posting as the new releases are built : )

Hide Download a Copy option from Ribbon and ECB SharePoint 2010 Document Library

Hey if you want to remove "Download a copy" option from SharePoint 2010 document library then add the below code. Now it depends on the requirement  1. If it has to be disabled in specific library only then  add a content editor web part and add the below code as html. 2. if it has to be disabled throughout the site then it is recommended to put it in the Master page. The Css hides the icon in the ribbon whereas the JavaScript overrides the default function of ECB to render the Send To option. <style type="text/css" > a[id$='Ribbon.Documents.Copies.Download-Large'] { display:none; } </style> <script type="text/javascript"> AddSendSubMenu = function (m,ctx) {} _spBodyOnLoadFunctionNames.push("resetAddSendSubMenu()"); function resetAddSendSubMenu(){ AddSendSubMenu = function (m,ctx) {}; } </script>

Delete all items from a SPListItemCollection

Hi Folks.Today my friend asked me a question on how to delete all the items of a list item collection. I told him to loop through all the items and delete it using the index.But it resulted in an exception. Then i suggested him to write a negative loop.That worked!  But me and my friend (Deba) found it rather funny that by default there is not simple way to delete all the items. Well here is the method which we used. protected void DeleteAllItemsInCollection(SPListItemCollection collListItems) { //Deletes all the items of list item collection for (int intIndex = collListItems.Count - 1; intIndex > -1; intIndex--) { collListItems.Delete(intIndex); } } Reference :  1.  MSDN Reference Link 2.  Another Good Reference for the same topic Cheers