Posts

Showing posts from November, 2012

SharePoint custom timer job running multiple times

Recently, I have come across with a problem where users are receiving 18 duplicate notification mails. We surprised that why the timer job sending 18 duplicate mails. Then we have checked the job history in QA and noticed that my job is executing 18 times daily. Again we went in to a big confusion. That is, why the job is executing multiple times and also why 18 times, why not less or more :) After digging some time we found that my web application has 18 content databases and our job running for each and every content DB. Not only my job, the rest of the jobs also running for each and every content DB. I think the rest of the jobs are handled some thing at code level due to this they did not come across with similar issue. Initially we thought there is some problem in QA server but later we found that it is our code problem. When we create a job we will add following constructors in our class file. public...

How to query list data using web service

In SharePoint, to query list data we can also use web services provided by SharePoint other than SharePoint API. We can call web services from two places one is JavaScript and another one is .Net client application. Here I will show you both methods. .Net client application To query list data we will use a web service called lists.asmx . 1. Create .net project either windows/console. 2. Add the web reference and the URL looks like http://<servername:portno>/_vti_bin/lists.asmx 3. Give the web reference name as ListsSvc . 3. Add the following code snippet to get list data. ListsSvc. Lists listService = new  ListsSvc. Lists (); // If the current user is having access you can use below code listService.Credentials = CredentialCache .DefaultCredentials; // In case if you want to pass specific user credentials listService.Credentials = new NetworkCredential ( "<username>" , "<password>" , "<domain>" ); string v...

How to delete a SharePoint timer job

Recently I got a problem with timer job that is there were two instances got created in central admin. One instance got created with first deployment and another instance got created with second deployment because there were some changes made in timer job. Even though, in feature deactivation event we have written a code to delete existing job but some how it's not get deleted. Now I got required to delete the old job. Unfortunately we do not have any option to delete job at central admin level. After googling I found power shell script to achieve this. Searching listing and find timer job to delete.We need an id. Get-SPTimerJob | where { $_.name -like “*<your search criteria>*” } |ft id,name Set job to a variable $job = Get-SPTimerJob -id <GUID> And delete it. $job.Delete() I got this information from the below blog. http://blog.bugrapostaci.com/2011/06/02/how-to-delete-sharepoint-timer-job-using-powershell/

Information Management Policy in Document Library

Image
Using Information Management policy settings you can perform required action after particular number of days. For example you can delete old items from a list/library after specified number of days using this policy. Here I will show you how to create this policy. Go to the Library Settings. Click on the link  Information management policy settings . Then you will see following screen. Here click on the Document link to create retention policy on documents. Select the Enable Retention option in the below screen. click on the link Add a retention stage... here, in the above screenshot if the document created date crosses 90 days then the item will be moved to Recycle Bin. Else you can also delete document permanently as well as we can start one workflow also using Action list. Finally click on OK to commit the changes.