Search This Blog

Total Pageviews

Thursday, March 17, 2011

Creating Custom Timer Job in SharePoint 2010




http://dotnetfinder.wordpress.com/2010/07/24/creatingcustomsharepointtimerjob2010/


http://msdn.microsoft.com/en-us/library/ff798313.aspx










Adding

To add a solution to the Farm solution store use the Add-SPSolution cmdlet:
Add-SPSolution –LiteralPath "C:\Deployment\MySharePointSolutionPackage.wsp"
To add a Sandboxed solution  use the Add-SPUserSolution cmdlet:
Add-SPUserSolution –LiteralPath "C:\Deployment\MySharePointSolutionPackage.wsp" –Sitehttp://webapplication/sitecollection
 

Installing

To install ( commonly known as deploy)  a Farm Solution we use the Install-SPSolutioncmdlet:
Install-SPSolution –Identity MySharePointSolutionPackage.wsp –WebApplicationhttp://webapplication –GACDeployment
To install ( commonly known as deploy)  a Sandboxed Solution we use the Install-SPUserSolution cmdlet:
Install-SPUserSolution –Identity MySharePointSolutionPackage.wsp –Sitehttp://webapplication/sitecollection


Updating

To update (know as upgrade in stsadm) a Farm solution use the Update-SPSolution cmdlet:
Update-SPSolution –Identity MySharePointSolution.wsp –LiteralPath “C:\Deployment\MySharePointSolutionPackage.wsp” –GacDeployment
To update (know as upgrade in stsadm) a Sandbox solution use the Update-SPUserSolutioncmdlet:
Update-SPUserSolution –Identity MySharePointSolution.wsp –Sitehttp://webapplication/site –ToSolution MySharePointSolutionPackage.wsp

Removing

To uninstall and remove FARM level solutions use the Uninstall-SPSolution and Remove-SPSolution cmdlets:
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplicationhttp://webapplication
Remove-SPSolution –Identity MySharePointSolution.wsp
To uninstall and remove Sandbox solutions use the Uninstall-SPSolution and Remove-SPSolution cmdlets:
Uninstall-SPUserSolution –Identity MySharePointSolution.wsp –Sitehttp://webapplication/sitecollection
Remove-SPUserSolution –Identity MySharePointSolution.wsp –Sitehttp://webapplication/sitecollection


To get a list of all of the powershell cmdlets that deal with solutions use:
Get-Command –noun *SPSolution*


To run all of the Administrative jobs that are queued:
Start-SPAdminJob

Workflow status codes (used for view filter)


Here is the list of the status codes used to maintain the workflow statuses. This list might be useful when anyone creates a view based on workflow status. If you are creating a view for a list filtered by the workflow status, you would need use the number rather than the words (e.g. 2 instead of In Progress, 4 instead of Cancelled etc)


Status
Value
Not Started0
Failed on Start1
In Progress2
Error Occurred3
Canceled4
Completed5
Failed on Start (retrying)6
Error Occurred (retrying)7
Canceled15
Approved16
Rejected17

Monday, March 14, 2011

Change browser icon in SharePoint 2010



To generate the icon files you can use the below link
http://tools.dynamicdrive.com/favicon/

copy the download image to your layouts folder

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\CompanyName

Find the below in your master page and replace the new icon url.

<SharePoint:SPShortcutIcon runat="server" IconUrl="/_layouts/images/CompanyName/favicon.ico"/>



Sunday, March 13, 2011

Hide the Upload Multiple links in the upload.aspx page

Hide the Upload Multiple links in the upload.aspx page

this is one of the easiest way to hide this from the script


<script type="text/javascript" >
if(document.location.href.match("Upload.aspx") =="Upload.aspx")
{
var hlink= document.getElementsByTagName("a");
for(var i=0;i<hlink.length;i++)
{
if(hlink[i].id.match("UploadMultipleLink") =="UploadMultipleLink")
{
hlink[i].style.display="none";
}
}

}
</script>



Thursday, March 10, 2011

SharePoint 2010 Search Results in Tabular Format

Common Date Time formulas for Sharepoint – Calculated Fields


Get Week of the year
=DATE(YEAR([Start Time]),MONTH([Start Time]),DAY([Start Time]))+0.5-WEEKDAY(DATE(YEAR([Start Time]),MONTH([Start Time]),DAY([Start Time])),2)+1
First day of the week for a given date:
=[Start Date]-WEEKDAY([Start Date])+1
Last day of the week for a given date:
=[End Date]+7-WEEKDAY([End Date])
First day of the month for a given date:
=DATEVALUE(“1/”&MONTH([Start Date])&”/”&YEAR([Start Date]))
Last day of the month for a given year (does not handle Feb 29). Result is in date format:
=DATEVALUE (CHOOSE(MONTH([End Date]),31,28,31,30,31,30,31,31,30,31,30,31) &”/” & MONTH([End Date])&”/”&YEAR([End Date]))
Day Name of the week : e.g Monday, Mon
=TEXT(WEEKDAY([Start Date]), “dddd”)
=TEXT(WEEKDAY([Start Date]), “ddd”)

The name of the month for a given date – numbered for sorting – e.g. 01. January:

=CHOOSE(MONTH([Date Created]),”01. January”, “02. February”, “03. March”, “04. April”, “05. May” , “06. June” , “07. July” , “08. August” , “09. September” , “10. October” , “11. November” , “12. December”)
Get Hours difference between two Date-Time :
=IF(NOT(ISBLANK([End Time])),([End Time]-[Start Time])*24,0)
Date Difference in days – Hours – Min format : e.g 4days 5hours 10min :
=YEAR(Today)-YEAR(Created)-IF(OR(MONTH(Today)<MONTH(Created),AND(MONTH(Today)=MONTH(Created),
DAY(Today)<DAY(Created))),1,0)&” years, “&MONTH(Today)-MONTH(Created)+IF(AND(MONTH(Today)
<=MONTH(Created),DAY(Today)<DAY(Created)),11,IF(AND(MONTH(Today)<MONTH(Created),DAY(Today)
>=DAY(Created)),12,IF(AND(MONTH(Today)>MONTH(Created),DAY(Today)<DAY(Created)),-1)))&” months,
“&Today-DATE(YEAR(Today),MONTH(Today)-IF(DAY(Today)<DAY(Created),1,0),DAY(Created))&” days”
 
 
8 Votes

Monday, March 7, 2011

The crawler could not communicate with the server. Check that the server is available and that the firewall access is configured correctly


If you see this message in the Crawl log of a content source, make sure that the site(s) it is crawling are accessible from the index server. Often one of the following has happened:
  • The web.config file of the crawled web application contains an error. Especially if the crawl was working yesterday and suddenly it stopped, check the web.config file on the Index server by loggin on to the index server, browse the site and check for errors. Remember to edit the web.config to show detailed error messages (search for ‘stack’ and turn the stack trace to ‘on’, next search for ‘errors’ and turn to ‘off’. Browse again. Sometimes there are solutions which change the web.config through either: web.config.merge.xml file as part of the solution (you will find them in the CONFIG folder) or through the object model. Like adding your own custom navigation provider entry and so on. Duplicates in the web.config file (like duplicate trust level entries) etc are not allowed.
  • The target site collection contains a web part error for instance on the default.aspx. Although I did not encounter this myself I read a blog post that said the crawl error was solved by deleting the faulty web part from the site using SharePoint designer
  • Also check the solution are not deployed correctly.Central Administration -> Solution Management (Manage Farm Solutions)

Method to get the no.of working days between two dates excluding weekends

public static int CalculateBusinessDays(DateTime startDate, DateTime endDate)
{
//Check if Start Date is greater than end date, return -1
if (startDate > endDate)
return -1;

DateTime dateTemp;
int weekDays = 0;
int weekEnds = 0;
TimeSpan tsDiff = endDate.Subtract(startDate);
//Calculate number of weekend days between two dates
for (int i = 0; i < tsDiff.Days; i++)
{
dateTemp = startDate.AddDays(i + 1);//starting from next day of starting date
if (dateTemp.DayOfWeek == DayOfWeek.Saturday || dateTemp.DayOfWeek == DayOfWeek.Sunday)
weekEnds++;
}
weekDays = tsDiff.Days - weekEnds;
return weekDays;
}

To convert Text column to Date column format in Sharepoint column

Suppose you have a column(named,"DateText") with text format and the value it returning is of type datetime("2009-06-18T00:00:00"),
To convert it into datetime format(mm/dd/yyyy),

first create a calculated column named Expiration Date, with datatype as datetime and with the follwing formula:

=IF(ISNUMBER(FIND("T",[DateText])),TEXT(LEFT([DateText],FIND("T",[DateText])-1),"mm/dd/yyyy"),TEXT([DateText],"mm/dd/yyyy"))

Then create one more calculated column with DateTime data type and use the following formula:

=DATE(YEAR([Expiration Date]),MONTH([Expiration Date]),DAY([Expiration Date]))

Troubleshooting User Profile Service

Sharepoint Error Message: “Your client does not support opening list with windows explorer”

I received the following message, when I tried to open document library in Windows explorer view: “Your client does not support opening list with windows explorer”

OS: Windows Server 2008 SP2 (x86)
Browser: IE 7



The solution:
By default, “Web Client” service is not installed with Windows Server 2008, you need to install “Desktop Experience” from Server Manager > Features






(If you are working on Multiserver Architecture then you need to enable it on all the web frontend servers)

Friday, March 4, 2011

Update the HyperLink Field Value using object Model





SPListItem olistitem= oList.GetItemById(itemidval);
SPFieldUrlValue ofldurl= new SPFieldUrlValue();
ofldurl.URL = "http://www.google.com";
ofldurl.Description = "Google";
olistitem["HyperLinkColumName"] =ofldurl;
olistitem.update();




Hide SharePoint Columns in New / Edit / View Form

Hide SharePoint Columns in New / Edit / View Form

Open the SharePoint Designer 2010, Go to the Corresponding List/ Library.

Open the New/Edit / View Item Aspx Page in Edit In Advance Mode add the Following script


<script language="javascript" type="text/javascript">

_spBodyOnLoadFunctionNames.push("hideFields");

function findacontrol(FieldName) {

   var arr = document.getElementsByTagName("!");
   // get all comments

   for (var i=0;i < arr.length; i++ )
   {
      // now match the field name
      if (arr[i].innerHTML.indexOf(FieldName) > 0)
      {         return arr[i];      }
   }
}

function hideFields() {

   var control = findacontrol("Title");
   control.parentNode.parentNode.style.display="none";
   control = findacontrol("Document Link");
   control.parentNode.parentNode.style.display="none";
   control = findacontrol("PublishDate");
   control.parentNode.parentNode.style.display="none";

}

</script>