So, in my live site when a user tries to access an item that's been deleted, SharePoint pops up this big ugly page that says in red letters "Server Error in '/' Application." It then gives details in equally fugly fonts but by that time the user is so confused and angry that they ignore everything and contact yours truly.
Ew.
I figured I should probably fix this so I tried to recreate it in my testing environment. Well, it looks all pretty and like an OOTB SharePoint page there. WTF??? Some testing environment.
After googling stuff like "custom sharepoint error page" and "customerrors sharepoint" and all sorts of other random junk and traipsing through IIS and web.config files and SharePoint Designer, etc. etc. etc. I came across SaurabhKV's blog which tipped me off to the solution. The CallStack attribute has to be set to false in the SafeMode element in the web.config file. Wait, huh? So it looks like this:
<configuration>
<SharePoint>
>SafeMode MaxControls="200" CallStack="false" ... >
...
</SafeMode>
Now I get pretty error messages that look like actual SharePoint pages instead of ugly ones that look like cr4p. Yay!
Monday, March 22, 2010
Wednesday, February 10, 2010
CAML Queries, DateRangesOverlap, and Today, oh my!
Well, recently SharePoint views became too limited for my requirements and I've been forced to create my own CAML queries. Yay. Even better, I want to be able to pull recurring events so I'm pretty much forced to use the relatively undocumented "DateRangesOverlap" element. Double yay!
For my first application, pulling all of the events in a week worked. My query looks something like this:
<Where>
<DateRangesOverlap>
<FieldRef Name='EventDate'>
<FieldRef Name='EndDate'>
<FieldRef Name='RecurrenceID'>
<Value Type='DateTime'>
<Week/>
</Value>
</DateRangesOverlap>
</Where>
I specify the CalendarDate for my query and life is good. Well, almost good. This query pulls 8 days of data (Sunday through Sunday) so if you iterate through a time range, you've got to do some cleaning.
Next, I needed to pull items for a specific day. I did a little digging and found that instead of "Week" I could also use "Day," "Month," or "Year." Yay! Just plug and chug, right?
WRONG.
"Day" doesn't work. Try "Day" and you'll get back 999 items. Um... that's like, sort of what I wanted, only totally not.
Well, turns out, Day is not a valid element here. "Today" is. You can use all sorts of fancy offset junk to get a specific day, but that just sounds annoying. Turns out, Microsoft doesn't really mean "Today" when they say "Today." They just mean "whatever date is specified for the query."
Sooo... I set up my query like before:
<Where>
<DateRangesOverlap>
<FieldRef Name='EventDate'>
<FieldRef Name='EndDate'>
<FieldRef Name='RecurrenceID'>
<Value Type='DateTime'>
<Today/>
</Value>
</DateRangesOverlap>
</Where>
then said:
query.CalendarDate = {target date};
and I get the results I want.
Woo hoo! That's it for this time.
For my first application, pulling all of the events in a week worked. My query looks something like this:
<Where>
<DateRangesOverlap>
<FieldRef Name='EventDate'>
<FieldRef Name='EndDate'>
<FieldRef Name='RecurrenceID'>
<Value Type='DateTime'>
<Week/>
</Value>
</DateRangesOverlap>
</Where>
I specify the CalendarDate for my query and life is good. Well, almost good. This query pulls 8 days of data (Sunday through Sunday) so if you iterate through a time range, you've got to do some cleaning.
Next, I needed to pull items for a specific day. I did a little digging and found that instead of "Week" I could also use "Day," "Month," or "Year." Yay! Just plug and chug, right?
WRONG.
"Day" doesn't work. Try "Day" and you'll get back 999 items. Um... that's like, sort of what I wanted, only totally not.
Well, turns out, Day is not a valid element here. "Today" is. You can use all sorts of fancy offset junk to get a specific day, but that just sounds annoying. Turns out, Microsoft doesn't really mean "Today" when they say "Today." They just mean "whatever date is specified for the query."
Sooo... I set up my query like before:
<Where>
<DateRangesOverlap>
<FieldRef Name='EventDate'>
<FieldRef Name='EndDate'>
<FieldRef Name='RecurrenceID'>
<Value Type='DateTime'>
<Today/>
</Value>
</DateRangesOverlap>
</Where>
then said:
query.CalendarDate = {target date};
and I get the results I want.
Woo hoo! That's it for this time.
Labels:
CAML,
DateRangesOverlap,
SharePoint,
SPQuery,
Today
Monday, January 18, 2010
Nothing New Today
Today I'm in master page hell. I'll try to document it if I end up troubleshooting my problem instead of just nuking it and starting over.
In the meantime, some jerk sent me this site: http://www.firstpersontetris.com/
If you enjoy retro video games, I'd highly recommend it.
In the meantime, some jerk sent me this site: http://www.firstpersontetris.com/
If you enjoy retro video games, I'd highly recommend it.
Friday, January 8, 2010
How to Hide List Views from the Drop Down List
If, like me, your SharePoint is closer to OOTB than not, when you create a new public list view the view automatically shows up in the drop down list in the upper right hand corner. This is neat if you want your users to be able to look at all of the views you create. Otherwise, not so much.
The Problem: I want people to be able to see the views I create but I don't want them to show up in the drop down list. I may or may not have accidentally created tons of views when I created new webpages in the Designer. Oops.
To remedy this I created a little command line program in C# that changes the Hidden property of the view. The MSDN documentation says that the SPView.Hidden property "specifies whether the view is hidden." Gee. Thanks. Helpful. Jerks. So, apparently this property lets you hide the view from the drop down list. I have no idea what else it does, though, so don't blame me if it blows your stuff up.
My code looks a little bit like this:
List<SPView> views = new List<SPView>();
foreach (SPView v in <my list>)
{
if (<criteria goes here>)
{
views.Add(v);
}
}
foreach (SPView v in views)
{
v.Hidden = true;
v.Update();
}
Yes, the two loops are necessary. Yes it's annoying. But yes, it works.
The Problem: I want people to be able to see the views I create but I don't want them to show up in the drop down list. I may or may not have accidentally created tons of views when I created new webpages in the Designer. Oops.
To remedy this I created a little command line program in C# that changes the Hidden property of the view. The MSDN documentation says that the SPView.Hidden property "specifies whether the view is hidden." Gee. Thanks. Helpful. Jerks. So, apparently this property lets you hide the view from the drop down list. I have no idea what else it does, though, so don't blame me if it blows your stuff up.
My code looks a little bit like this:
List<SPView> views = new List<SPView>();
foreach (SPView v in <my list>)
{
if (<criteria goes here>)
{
views.Add(v);
}
}
foreach (SPView v in views)
{
v.Hidden = true;
v.Update();
}
Yes, the two loops are necessary. Yes it's annoying. But yes, it works.
Labels:
C#,
Hidden,
SharePoint,
SharePoint Designer,
Views,
Visibility
EWS, Error 403, and IIS 6.0
When I tried to navigate to http://(mysite)/ews I got an HTTP error 403 with the message "The website declined to show this webpage". The details say "Internet Explorer is able to connect to the website, but Internet Explorer does not have permission to display the webpage..."
This reads to me like IIS is saying "I don't feel like showing you this page. Maybe tomorrow..."
Ugh. Thanks for being descriptive!
To fix this, all I had to do was go into IIS, navigate to the root for EWS, click Default Document --> Add... then type in "exchange.asmx" (no quotes).
Note that exchange.asmx redirects to services.wsdl, at least with my configuration.
Also, I probably didn't really need to do that to be able to use my Web Services, but hey. I didn't know that going in and when I see an error, I troubleshoot it.
This reads to me like IIS is saying "I don't feel like showing you this page. Maybe tomorrow..."
Ugh. Thanks for being descriptive!
To fix this, all I had to do was go into IIS, navigate to the root for EWS, click Default Document --> Add... then type in "exchange.asmx" (no quotes).
Note that exchange.asmx redirects to services.wsdl, at least with my configuration.
Also, I probably didn't really need to do that to be able to use my Web Services, but hey. I didn't know that going in and when I see an error, I troubleshoot it.
Labels:
EWS,
Exchange Web Services,
HTTP 403,
IIS 6.0
Filter by Person or Group Column Type
The Problem: I have a column called Attendees of the type "Person our Group." Furthermore, Attendees can contain multiple entries. When someone is viewing this view, I'd like them to be able to only see the items in which they are listed as an attendee.
When I try to filter by the criterion Attendees contains [Me] I get the following error:
"The filter type you selected cannot be used with this type of column. You can apply the 'contains' operator only to the columns that have the type Single line of text, Multiple lines of text, or Choice. Specify a different operator for the filter or change the column type. You can then attempt to create the filter again."
Lame!
To get around this, I use SharePoint Designer.
First, through the web interface I create the view that I want and filter on a random text column (e. g. randomTextColumnName contains [Me]). If I view the page now it'll say <!-- #RENDER FAILED -->. Whatever Microsoft.
To fix this, I now open the page for the view in the Designer and search for the internal name of my randomly chosen text column. When I get to the code that looks kind of like this:
...Contains><FieldRef Name"TextColumnName"/><...
(note that the quotation marks might read as " - same difference for our purposes)
I can then change "TextColumnName" to the correct, internal name of the column (in my case, Attendees). Save and you're done.
Yeah. That's it. Silly, huh?
When I try to filter by the criterion Attendees contains [Me] I get the following error:
"The filter type you selected cannot be used with this type of column. You can apply the 'contains' operator only to the columns that have the type Single line of text, Multiple lines of text, or Choice. Specify a different operator for the filter or change the column type. You can then attempt to create the filter again."
Lame!
To get around this, I use SharePoint Designer.
First, through the web interface I create the view that I want and filter on a random text column (e. g. randomTextColumnName contains [Me]). If I view the page now it'll say <!-- #RENDER FAILED -->. Whatever Microsoft.
To fix this, I now open the page for the view in the Designer and search for the internal name of my randomly chosen text column. When I get to the code that looks kind of like this:
...Contains><FieldRef Name"TextColumnName"/><...
(note that the quotation marks might read as " - same difference for our purposes)
I can then change "TextColumnName" to the correct, internal name of the column (in my case, Attendees). Save and you're done.
Yeah. That's it. Silly, huh?
Labels:
Filter,
Person or Group,
SharePoint,
SharePoint Designer,
Stupid Tricks
Friday, December 18, 2009
Some Background
I'm starting this blog for two reasons. One, I'm ditzy and I forget how to fix things after I've figured them out. Months later, I'll run into the same problem and I have to figure out the solution all over again. Reason number two, I use information other people have posted in their blogs relentlessly and I hope that some of my insights can help other devs out there as well.
I will focus mainly on SharePoint and C#. I work for a small company, though, so the types of issues I encounter cover a pretty wide range of stuff.
Happy coding!
I will focus mainly on SharePoint and C#. I work for a small company, though, so the types of issues I encounter cover a pretty wide range of stuff.
Happy coding!
Subscribe to:
Posts (Atom)