Monday, June 15, 2015

Enabling Scheduling for Document Library

Follow the below steps to enable scheduling.


Goto Library Settings in Document Library

Click Versioning Settings
Enable Content Approval. Choose Create major and minor (draft) versions for version history. Then Click ok.

Click Manage Item Scheduling in Library Settings

Enable Item Scheduling and Click ok
We done with settings which is needed to schedule a document. Now we may see how to schedule an item. Upload a new document now.

Give the schedule property.


Then approve the document for to schedule it. Publish the major version of document.


Now Approval Status changed as Pending


Approve it



Now, Approval status changed as Scheduled.


Once we login as member of group. There is no document at 8.32 PM. Because we scheduled at 8.40PM


At 8.40 PM. Approval Status of the document changed as Approved. So it will be visible all the user.

Document will be in draft state after scheduled time is over.

That's All !!!!! :) 

Tuesday, June 9, 2015

Set "All day Events" as default in SharePoint Calendar


We have "All day Event" option in SharePoint calendar list. Let me explain about how to set "All day event" by default. First Add a content editor webpart in Newform.aspx of calendar list. Then, Paste the below script in content editor

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>

<script>
$(document).ready(function(){

if (!$('span[title="All Day Event"] > input').attr("checked"))
{
  $('span[title="All Day Event"] > input').click();
}

});
</script>

Save Content Editor and Click Stop Editing in the ribbon. Now we can see the "All Day Event" set for an event by default. 

Monday, June 1, 2015

Add / Remove Event Receiver from SharePoint List

Introduction

As all we know about event receiver in SharePoint. Let me explain how to add and remove this Event Receiver in the list.

Add Event Receiver


SPList list = web.Lists["List Name"];

var eventReceiverName = list.Title + SPEventReceiverType.ItemAdded;

if (list.EventReceivers.Cast<SPEventReceiverDefinition>().All(x => x.Name != eventReceiverName))
 {
var className = "Class name of Event Receiver";
var assemblyName = "Assembly name of dll";
web.AllowUnsafeUpdates = true;
list.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, className);
web.AllowUnsafeUpdates = false;
}

Remove Event Receiver

 SPList list = web.Lists["List Name"];
 for (int i = 0; i < list.EventReceivers.Count; i++)
{
               if(list.EventReceivers[i].Type.Equals(SPEventReceiverType.ItemAdded))
               {
                   list.EventReceivers[i].Delete();
               }
}

Tuesday, May 19, 2015

What's happening webpart is showing incorrect value in community site SharePoint 2013

Introduction

Most of us came across about this issue, which is count of Members, Discussion and Replies. Normally, These values are tracking in properties. In Some cases, It will not update properly. Let see how to update this.


Community site properties 

Open your community site in SharePoint Designer. Click Site options in top ribbon



Then we can able to see the parameters (properties) of site.


We can find the Community_MemberCount there, which is used to keep member's count of community.

Update the properties using Event receiver

We need to update the property when the user has leave from Community Member list. So, I have written the code in Community Member list event receiver to update the property. Members are not deleted from the list. They have changed the flag when user enforced to delete. So we need to code it when ItemUpdated


public override void ItemUpdated(SPItemEventProperties properties)

        {

            var web = properties.Web;

            var currentAllowUnsafeUpdatesVal = web.AllowUnsafeUpdates;
            try
            {
               var membersCountQueryCAML = "<Where><Eq><FieldRef Name='MemberStatusInt' /><Value Type='Integer'>1</Value></Eq></Where>";
            var membersCountQuery = new SPQuery();
            membersCountQuery.Query = membersCountQueryCAML;
            
                var membersCount = membersList.GetItems(membersCountQuery).Count;
                web.AllowUnsafeUpdates = true;
                if (web.AllProperties.ContainsKey("Community_MembersCount"))
                {
                     web.AllProperties["Community_MembersCount"] = membersCount.ToString();
                    web.Update();
                 }
                base.ItemUpdated(properties);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                web.AllowUnsafeUpdates = currentAllowUnsafeUpdatesVal;
            }
        }

Then, deploy / upgrade your solution in your community site. Now Whats happening webpart will give the correct member's count.

Increase the Social Comment Webpart (NoteBoard) item count

Introduction

As all we know, We have Noteboard webpart in SharePoint which is used to comment about particular page. Refer this blog for get intro about it. 

The items count of this webpart is set as 3 by default. We can able to change it as we wish.



        <prfx:SocialCommentWebPart runat="server" ChromeType="TitleOnly" Title="Comments" WebPartPropertyDisplayItems="10" />

Set WebPartPropertyDisplayItems with the count which you want.  That's all Noteboard webpart will display number of items which you gave.

Sunday, April 19, 2015

Delete custom Timer job in SharePoint using powershell

Introduction

Everyone is experiencing the situation to delete the timer job from CA. Here, i am providing an example to delete it using powershell command.

Get-TimerJob | where { $_.name -like "*your timer job name*" } | ft id,name

This command will give the ID and Name of the Timer job. Then, we may proceed delete command with timer job id.

$job = Get-SpTimerJob -id Your timer job id
$job.delete()

Timer job will be deleted from SharePoint farm.





Note: Restart the SPTimer service and IIS for safer side.

Thursday, March 12, 2015

Deleting Tags from Site in SharePoint 2013

Introduction

As all we know about tagging concept in SharePoint 2013. This is one of the main feature in SharePoint 2013 in content management. We can able to tag our interested content in SharePoint site. That tags will get populated in my profile. You can use Tag Cloud webpart to see those tags in team site. 

Tag Cloud webpart
 Click Here to get more knowledge about Tags. Let we see about how to delete those tags from site.

Deleting Tags

Do the following steps to delete the tag

  • Go to Central Administration
  • Click Manage Service Application in Application Management area 
  • Click Manage Meta Data Service
  • Expand System in Taxonomy Term Store at left panel
  • Expand the context menu in tags and Click Delete Hashtag
  • That's all tag will be deleted from the SharePoint sites. #slider tag is removed from tag cloud webpart