Sunday, December 14, 2008
Saturday, December 6, 2008
Create SharePoint Alerts Programmatically
Using following code you can create alerts
SPUser user = mySite.Users["domain\user"];
SPAlert newAlert = user.Alerts.Add();
newAlert.Title = list.Title;
newAlert.AlertType = SPAlertType.List;
newAlert.List = list;
newAlert.Properties["eventtypeindex"] = "1";
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
newAlert.Update(false);
If you want to set an alert for a list, you have to set the AlertType property to SPAlertType.List and set the List property to an instance of the SPList class.
If you want to set an alert for a list item, you have to set the AlertType property to SPAlertType.Item and set the Item property to an instance of the SPListItem class, in that your code should be
newAlert.AlertType = SPAlertType.Item;
newAlert.Item = item;
You can change following codes depending on what action you want to set alert using "eventtypeindex"
all = 0
added = 1
modify = 2
deleted = 3
web discussions = 4
If you want to send Alert daily you can change the AlertFrequency as mentioned below
newAlert.AlertFrequency = SPAlertFrequency.Daily;
newAlert.AlertTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 8, 0, 0);
If you are subscribing alerts for some other user, you should be the administrator or should have permisssions to manage alerts thne add your code with following code
SPSecurity.RunWithElevatedPrevilages(delegate()
{
web.AllowUnSafeUpdates=true;
// Add your code here
});
Friday, October 24, 2008
I am a Microsoft Certified Technology Specialist in MOSS
Today I passed another exam i.e. Microsoft Office SharePoint Server 2007, Application Development exam.
The exam 70-542 were max 80 minutes long and there were 40 questions.
I felt very bad prepared, but I guess that something must had stuck since there were so many lucky guesses :-). I didn’t find it easy at all.
Last time I had a feeling of “knowing the stuff”. This time the feeling was more like “familiar stuff”.
Wednesday, October 1, 2008
Monday, July 28, 2008
Code blocks are not allowed in this file.
By adding some inline code in a masterpage or pagelayout files or newform/editform/dispforn, you get the following error message:
An error occurred during the processing of xxxx.aspx. Code blocks are not allowed in this file.
It is basically a securiry warning which need to add an exception to the file to allow code to be run in the aspx.To get this working you need to modify the web.config of your web application. For instance, if you want to allow server side script on pages from the masterpage & pagelayout gallery you have to modify the PageParserPaths into:
<pageparserpaths>
<pageparserpath virtualpath="/_catalogs/masterpage/*" compilationmode="Always" allowserversidescript="true" includesubfolders="true".>
</pageparserpaths>
Saturday, June 14, 2008
Explorer View is too slow
The explorer view feature is one that is VERY popular with end users AND it provides perhaps this simplest way to "Bulk Load" content into SharePoint, when it works, it works really well, however when it doesn't, getting to the bottom of why can be a real pain. I went as far a reinstalling office 2007 and even installed IE8 RC1 and the problems persisted. I then ran a registry an file trace on my PC to try and figure out what was happening and noticed a lot of TCPIP related info, but no luck. The lack of performance seems to be related to a setting in Internet Explorer: under Tools, Internet Options, Connections, LAN Settings, you need to uncheck automatically detect settings. This magically increases the speed of your Explorer View, but what is even better: drastically decreases the load time of Office documents when opening them from SharePoint.
I had IE7 and office 2007 installed. When I opened a document straight from SharePoint it took too much time, even when I opened a document library in Explorer view it also took too much time. I also tried by right clicking on an Explorer view also took too much time to give me the menu.
There are a few causes and solutions for this:
See this article to Troubleshooting the SharePoint Explorer View:
Monday, June 9, 2008
"is Greater than or equal to" option is missing in the filter criteria in Sarepoint Designer
Most of the users face some problems with not having the right operators in the Filter Criteria dialog of a DataForm Web Part speciall when they are trying to filter by was a date.
After doing lots of R & D I found out two reasons for not able to see this option. Here is the resolution
Resolution 1
One of my sharepoint there was a Lookup column which referred to a list that no longer existed. Note the lack of List name for where it’s getting information:
After deleting this column, I am able to see my all the missing options
After deleting this column, I am able to see my all the missing options
Resolution 2
I also got another solution from http://geekswithblogs.net/naijacoder/archive/2007/10/15/116060.aspx
Once of my end user have same problem and using option 2, his problem was resolved.
Tuesday, May 20, 2008
How to Shrink SharePoint content database size?
Run following SQL command to free up space of sharepoint content database
dbcc shrinkdatabase(WSSContentDatabaseName)
Saturday, May 3, 2008
How to Hide Fields in SharePoint List Form Pages using jQuery
Yesterday, one of friend ask me can we show/hide fields in Newform.aspx and Editform.aspx by clicking on checkbox. It can be done thru sharepoint designer with some rules. But I used jQuery with few lines of code in Task List. I added 1 more field i.e. ShowFields as choice field.
Then I added a content editor webpart on newform.aspx. MOSS wont allow to edit newform.aspx and editform.aspx. To add webpart on newforn.aspx / editform.aspx, add in &ToolPaneView=2 on the end of the url. So your url for newform.aspx will be http://portal/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fportal%2FLists%2FTasks%2FAllItems%2Easpx&ToolPaneView=2
In source editor of content editor web part, I have added following script
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script>
$(document).ready(function()
{
$("input[title$='ShowFields']").click(function()
{
$("input[title$='Title']").parent('span').parent('td').parent('tr').toggle();
$("nobr:contains('Start Date')").parent('h3').parent('td').parent('tr').toggle();
$("nobr:contains('Due Date')").parent('h3').parent('td').parent('tr').toggle();
});
});
</script>
and close the webpart page. Then open newform.aspx, now whenever I click on Showfields Checkbox then Title/Start Date/Due Date fields are hidden, once I uncheck this it shows the fields again.
Saturday, April 19, 2008
How to set permission and restrict view to particular user
Using following tool you can set permissions to views and restrict views to particular users. This feature is not available in MOSS 2007.
http://www.codeplex.com/SPViewPermission
Saturday, April 12, 2008
How to set field permission in Sharepoint List
Folllowint tool providing advanced settings to customize list form rendering in new, display and edit mode.
http://splistdisplaysetting.codeplex.com/
Saturday, March 29, 2008
Tuesday, February 12, 2008
Microsoft Best Practices Analyzer for 2007 Microsoft Office System
The Microsoft Best Practices Analyzer for Windows SharePoint Services 3.0 and the 2007 Microsoft Office System Best Practices Analyzer programmatically collects settings and values from data repositories such as MS SQL, registry, metabase and performance monitor. Once collected, a set of comprehensive ‘best practice’ rules are applied to the topology.
Administrators running this tool will get a detailed report listing the recommendations that can be made to the environment to achieve greater performance, scalability and uptime.
http://www.microsoft.com/downloads/details.aspx?familyid=cb944b27-9d6b-4a1f-b3e1-778efda07df8&displaylang=en
Thursday, January 24, 2008
How to turn off custom error message
Take a backup of web config now follow these steps to do that:
Open the web.config
Find "customErrors" and turn those "off".
Next do a search for "callStack" and set the value to "true"
Save the web.config and you are ready to go.