Thursday, November 1, 2012

SharePoint 2010 Birthday webpart

Hi ,

I had a small requirement from my manager to display the team mates birth days in the team site for the current month.

I searched for the  already existing solutions in the net and able to replicate one of them using a simple OOB approach.

You just need a custom list to store the team mates names and birth day dates and need to do some calculated columns . Thats enough.

Below are the steps explained.

  1. Create a custom list named TeamBirthdayList and add the columns name, birthday as date type and other details if needed to display like mail id and mobile no.
  2. create a column named "currentdate" and make default value as today's date with date only.
  3. Create two calculated columns named "startmonth" and "endmonth".
  4. startmonth calulated formula as DATE(YEAR(currentdate),MONTH(Birthday),1)
  5. endmonth calulated formula as DATE(YEAR(currentdate),MONTH(Birthday)+1,1)-1.
  6. Now create another column named "BirthdayOrder" as calculated column to sort the list according to the date. the formula will be like this : DATE(YEAR(currentdate),MONTH(birthday),DAY(birthday))
  7. Now, add this list as listview webpart in the page and change the view settings like below steps. 
  8. Sort the items as per birthday order field .
  9. IN the filter section, startmonth is less than or equal to [Today] and endmonth is greater than or equal to [Today]
Thats it. your teams birthday webpart is ready and you can customize the styles using xslt.

Saturday, October 20, 2012

SharePoint 2010 calendar color indiacator using Overlays

Hi Guys,

Recently I got a requirement from my team to develop vacation calendar along with color indicators for each category.

Later started search, I found many good articles on the internet, but I want to finish through OOTB. So I got the below method to work exactly and writing down the below  lines to be helpful for others and for my own tracking .

Step1: Create one calendar list and name it as vacation calendar. Once created, go to settings and then change category choice items. Add your own categories upto 7 ( as OOTB offers not more than this colors).  For e.g. I created 3 categories named "Vacation", "Training", "Work from Home"

Step2: Create a new calendar view named Vacation view and specify Category is equal to Vacation in filter section.

Step 3: Create other 2 views like in step 2 with specifying categories is equal to their category values.



Step 4: Create a new view name Overlay view and specify Category is blank in Filter section..




Step 5: Create Overlay view as the default view and click on Overaly button in ribbon.



Step 6: Create new calendar link in Overlay section and specify names and select appropriate site with click on resolve button.

Specify the color from the list and fill the remaining details.


Check Always show check box.
Step 7: Create another two calendar in Calendars Overlay section using above step for other two cateogories.

Thats it. Try adding different entries with various categories and you can find different colors. Make sure Overlays view is your default view, so that when you add it as list view webpart, make sure to change the view to Overlay view in tool bar setting.


You would get final look and feel like this,




Cheers,
Anil

Sunday, October 14, 2012

Powershell startup

Hi Guys,

I started learning powershell scriping recently and I noted my learning updates here for quick reference

  1.  To add powershell snap-in
           Add-PSSnapin Microsoft.Sharepoint.Powershell

If you are unable to add snapin to the powershell console, you may not have sufficient permissions to do the scripting.

Here are the steps to get the permissions to run the scripts.

You should have access to sharepoint shell configuration database and here is the cmdlet.

Add-SPShellAdmin -username contoso\user1

You have to perform the above step by using farm administrator privileges. The above command adds the user name specified to the Sharepoint_shell_access role on the configuration database.

If you want to give permission to a specific content database for a webapplication, specify the database parameter
Add-SPShellAdmin -username contoso\user1 -database guid



   2.    To get help on any command,
           help Get-SPSite

    3.   To get examples on the cmdlet.

          Get-SPSite -examples

4.        To get information about the site,

          Get-SPSite http://litware | select owner, Name, Description

5.       To know about the features in a site collection

         Get-SPFeature -site http://litware
6.      To activate the features

         Enable-SPFeature -identity GUID -url http://litware

7.    To install the feature,

        Install-SPFeature featurename
        e.g Install-SPFeature  MyCustomFeature
       Before installing the feature, make sure that, the feature files are deployed correctly in 14 hive features    folder.

8.     To add the solution to the farm,
       Add-SPSolution solutionname
       e.g. Add-SPSolution  "D:\mycustomsolution.wsp"

9.    To deploy the solution to the GAC
        Install-SPSolution -identity mycustomsolution.wsp -webapplication http://litware  -GACdeployment

 10. To update the solution
       Update-SPSolution -identiy mycustomsolution.wsp -literalpath "d:\mycustomsolution.wsp" -GACdeployment

11. To uninstall the solution from the web application
      Uninstall-SPSolution -identity mycustomsolution.wp -webapplication http://litware

12. To remove the solution from farm
      Remove-SPSolution -identity mycustomsolution.wsp

Below is the example
Powershell script to install a feature for all the site collections in a farm with known GUID

Add-PSSnapin microsoft.sharepoint.powershell
$webapplications=Get-SPWebapplication
foreach($webapp in $webapplications)
{
$id=$webapp.id;
write-host "processing webapplication with name, id" + $webapp.Name, $id

foreach($site in $webapp.Sites)
{
$name=$site.Name;
write-host "processing site collection -" + $name
foreach($web in $site.AllWebs)
{
write-host "processing web" +$web.title
$features=$web.features;
if($web.features[GUID] -eq $null)
{
enable-spfeature -identity GUID -url $web.url -confirm:$false
}

}
}

}

Sunday, August 26, 2012

Configuration of SharePoint workflow tasks in Outlokk

When you work with approval workflow in SharePoint 2010 and trying for do approval/reject for the workflow throug Outlook, you may face the problem of trusted sites security issue and not able to do approval/reject of the workflows,

Below are the steps to resolve these issues.

1. Out look sharepoint configuration

1. In SharePoint site, Go to “Tasks” list.


2. On the top ribbon, click on “List” tab and then click on “Connect to Outlook”. Below is the screen shot.







3. After the above step, click on “Yes/Allow program” for the windows prompt messages.

4.  open your internet explorer then  Click on internet tools --> Options --> Security tab


5. Click on “Trusted sites” and enter the sharepoint ur and then click ok.








SharePoint 2010 OOB approval workflow customization


Hi Guys,

Recently I worked on a requirement to customize the OOB approval workflow in sharepoint designer.

The customer is looking for the  email customization at each stage of the approver  and the workflow initiator.

For e.g., if there are two approvers sequentially and if the approver approves the task, then second approver should know that the document was initially approved by first approver and waiting for the current approval from him self and similar notification to workflow initiator so that the initiator can contact drectly the pending approver to get task immediately.

Below are the steps, I implemented in SharePoint Designer   for acheivimg this customization.

Go to SP designer and open the workflows section of the site.

Select Approval workflow and do right clcik and then do copy and modify option.

After that paste the work flow and change the title and desctiption as required.

Once it it ready, click on Edit Workflow link and then click on the associate workflow part.

image comes here

Here you find 4 links to modify the task options like "Change the behaviour of the single task" , "Change the behaviour of overall task process" etc.

Click on "Change the behaviour of single task" and then do check for the different conditions about the task.

Go to the condition "if task Extenal participant is empty". there is already existing notiffication email action available, Do modify that with your content.

image comes here.

You can address approver  dsiplay name, document link can be embedded here, "Open this task"  link can be added inside the mail body.

image comes here.

Similary if you want notify the initiator about the task approvers, add the similar email action below this and customize the email body accordingly.

image comes here.

Once the approver do the approval/rejection, he can be notified through mail saying that the document is approved/rejected.

This can be done with adding email condition in the below way.

image comes here.




Sunday, July 1, 2012

Audience compilation status not idle

Hi Guys,

We had a situation recently in our 2010 server, the audience compilation job status is always compiling and not changed to idle. After I tried several ways to investigate the issue, there is no luck.

After I tried in Google, found the below information to solve the issue.


Open SharePoint Management Shell

Note: Run as administrator

Execute:

$runjob=[Microsoft.Office.Server.Audience.AudienceJob]::RunAudienceJob($args);

From the output copy the Application ID of the respective User Profile Service Application

For e.g., f4c2b7e2-ce7b-465d-868f-66164af37013

The Audience Compilation is preceded by following executable: AudienceJob.exe and we can force stop or start the compilation using PowerShell.

To stop execute:

Audiencejob.exe f4c2b7e2-ce7b-465d-868f-66164af37013 0

Note: Application ID and 0 or 1 indicates Stop or Start

After we successfully stopped the audience job we then started a full compilation executing following

Audiencejob.exe f4c2b7e2-ce7b-465d-868f-66164af37013 1



MOSS 2007: Power shell script for finding sub sites memory

Hi Guys,

I had a requirement from my client to provide them the report contains all the sub sites memory consumption in a site collection.
In Moss 2007, we don't have any OOTB to find the memory consumption for each sub site.

After tried in Google, I found the below power shell script that could be useful .


 function GetWebSizes ($StartWeb)  
 {  
   $web = Get-SPWeb $StartWeb  
   [long]$total = 0  
   $total += GetWebSize -Web $web  
   $total += GetSubWebSizes -Web $web  
   $totalInMb = ($total/1024)/1024  
   $totalInMb = "{0:N2}" -f $totalInMb  
   $totalInGb = (($total/1024)/1024)/1024  
   $totalInGb = "{0:N2}" -f $totalInGb  
   write-host "Total size of all sites below" $StartWeb "is" $total "Bytes,"  
   write-host "which is" $totalInMb "MB or" $totalInGb "GB"  
   $web.Dispose()  
 }  


 function GetSubWebSizes ($Web)  
 {  
   [long]$subtotal = 0  
   foreach ($subweb in $Web.GetSubwebsForCurrentUser())  
   {  
     [long]$webtotal = 0  
     foreach ($folder in $subweb.Folders)  
     {  
       $webtotal += GetFolderSize -Folder $folder  
     }  
     write-host "Site" $subweb.Title "is" $webtotal "Bytes"  
     $subtotal += $webtotal  
     $subtotal += GetSubWebSizes -Web $subweb  
   }  
   return $subtotal  
 }  

 function GetFolderSize ($Folder)  
 {  
   [long]$folderSize = 0   
   foreach ($file in $Folder.Files)  
   {  
     $folderSize += $file.Length;  
   }  
   foreach ($fd in $Folder.SubFolders)  
   {  
     $folderSize += GetFolderSize -Folder $fd  
   }  
   return $folderSize  
 }  

After you run the above scripts together, you can call it with the following PowerShell command: GetWebSizes -StartWeb

The start url could be any subsite url, that may not be a top level site.

Note: The script is written om SharePoint 2010 version, by changing the Get-SPWeb cmdlet to 2007 version ( like $site=new object Microsoft.Sharepoint.SPSite('ur'))  ,  it could work well.


Saturday, June 30, 2012

Error in Windows SharePoint timer services

Hi Guys,

Recently,  I was unable to get my email attached documents in the document repository, though the document library  was enabled with  incoming email settings successfully.

After restarted the smtp service , it was no luck. Then I did check on the drop folder of the message folder in inertub, all the sent documents were struck in the drop folder.

Later, investigated the 12 hive, ULS logs, I came to know that all the share point timer services are not updating successively and they were struck in dead lock.

So, here is the process, I had to resolve the issue.

1. Go to service.msc and the stop the windows sharepoint timer services.
2. Navigate to folder " %ALLUSERSPROFILE% \Application Data\Microsoft\SharePoint\Config\
" and then take the back up of xml files in the folder.
3. Edit the cache.ini file with changing the number to '1' and save it.
4. Restart the windows sharepoint timer services in services console and then do iis reset.
5. Go to Central administration window, then check the timer services status.

This is the steps you need to for other servers in the farm with stooping the services one by one, then delete or back up the xml files and the restart the service in the servers.

If you have any of  the below issues, you could do the above approach.


- Scheduled Audience compilation is not happening anymore?
- Scheduled Index crawll is not happening anymore?
- Scheduled Profile Import is not happening anymore?
- Users Memberships or My Settings properties are not updated anymore?


Saturday, March 24, 2012

MOSS Recycle bin stage 1 and stage2


Share point is a great content management tool, but of course suddenly you may receive notifications like memory space issues, add more disk space etc.
Customers reach out to share point administrators, where is the size consuming, what are the cost details, they want all the reports consumed by each site.

To better manage these things in advance, admins need to understand the stage 1 and stage 2 recycle bin concepts.

Generally, MOSS manages the user deleted things in two ways.

Stage One:
  • User directly deletes the data in the site, it will be moved to recycle bin.
  • Deleted item/data stays in the recycle bin for 30 days. (default setting in central admin)
  • It will consume the space under site quota.
  • User can restore the deleted data/item.

Stage Two:

After 30days (default setting in central admin), this deleted item will no longer be available to the end user, it would be moved to stage 2.
  • Only site collection admin can view and restore this item
  • This will not consume the data under site quota limit.
  • Deleted item will stay in the second stage recycle bin for 30 days .
  • After 30 days, it will be permanently deleted in the content database.
The recycle bin stage 1 and stage 2 setting for a site collection can be changed in the general setting in central administration.

The url ends with: _admin/vsgeneralsettings.aspx
(e.g: http://ca:80/_admin/vsgeneralsettings.aspx)

Select the required web application from drop down and change the settings as shown below figure.


If site collection admins want to manually delete the stage1 or stage 2 recycle bin items , they could navigate to site collection administration -->Site collectino Recycle bin.

There , they could take the necessary actions to delete or restore the items from the stage 1 and stage 2.

Only site collection admins can have this privilege.






Thursday, March 8, 2012

sharepoint 2007 power shell script to delete old versions

Recently I had a requirement from customer to delete old versioned documents in the document library to get the free space.

Since share point saves each version as a new copy with occupying the memory in database server, we should keep the limit on major and minor versions to consume the memory space on the database server.

Its very cumbersome to manually go and delete each version of the document in the document library


Below power shell script allows to delete all the old version copies from document library.

 [System.Reflection.Assembly]::Load(”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
$siteurl="http://siteurl";
$spsite=new-object Microsoft.Sharepoint.SPSite("$siteurl");
$spweb=$spsite.OpenWeb("$weburl");
$splist=$spweb.GetList("/sites/mydocumentlibray");
foreach($splistitem in $splist.items){
$file=$splistitem.File;
$file.Versions.DeleteAll();
}
$spweb.dispose();
$spsite.Dispose();
write-host ">>>finished at "(get-date) `n;


If you want to keep the limited versions in a document library,
the below power shell script will help you.

 [System.Reflection.Assembly]::Load("Microsoft.Sharepoint,Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
$siteurl="http://siteurl";
$listname="TempEmailDocument";
$spsite=new-object Microsoft.Sharepoint.SPSite("$siteurl");
$spweb=$spsite.OpenWeb();
$splist=$spweb.Lists["$listname"];
$listitems=$splist.items;
$VersionsToKeep=2;
foreach($item in $listitems)
{
$currentVersion=$item.Versions.Count;
if($currentVersion -gt $VersionsToKeep)
{
for($index=$currentVersion-1; $index -gt $VersionsToKeep-1;$index-- )
{
$file=$item.Versions[$index].ListItem.File;
$file.Versions[$index].Delete();
$splist.Update();
write-host "deleting ...." + $item.Name +$file.Versions[$index].VersionLabel+ "...";
}
}
}
$spweb.Dispose();
$spsite.Dispose();
write-host ">>>finished at "(get-date) `n;

In the above code, the number of limited versions are 2.