<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Views</title><link>https://www.infopathdev.com:443/forums/42.aspx</link><description> </description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Switching view in a catch block</title><link>https://www.infopathdev.com:443/forums/thread/91131.aspx</link><pubDate>Fri, 05 Jul 2013 18:43:34 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:91131</guid><dc:creator>BAltner</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/91131.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=42&amp;PostID=91131</wfw:commentRss><description>Greetings:

I may be trying to do the impossible, but I&amp;#39;ve seen some really clever solutions posted to this forum so I decided to ask for help before giving up.  Here&amp;#39;s the situation:&lt;p&gt;

1. SharePoint 2010 forms library with the &amp;quot;Content Approval&amp;quot; option set to true. This means that only an approver or the last one to change the form can view it or edit it while it is still pending.&lt;p&gt;

2. A non-approver viewing the contents of the library therefore sees only approved versions of a form: if a later version of the form, still pending,  exists he/she won&amp;#39;t see it and might try to edit the one he can see, which throws a System.Net.WebException.&lt;p&gt;

3. I catch the exception and try to switch views to show an error message (this is web-based so I don&amp;#39;t have a MessageBox) but even the view does not switch using this.ViewInfos.SwitchView(&amp;quot;ErrorMessage&amp;quot;).&lt;p&gt;

4. Debugging shows me that the this.CurrentView.ViewInfo.Name has inded changed from default to &amp;quot;ErrorMessage&amp;quot; but that is apprently ignored.&lt;p&gt;

5.  I tried to fix this by setting a field value, &amp;quot;exceptionThrown&amp;quot; to TRUE and switching it via this.SetDefaultView(&amp;quot;ErrorMessage&amp;quot;) in the FormEventsLoading method, but this doesn&amp;#39;t work either because if you can&amp;#39;t edit the form you can&amp;#39;t set a flag, so it is always FALSE and the view doesn&amp;#39;t switch.&lt;p&gt;

The best workaround that I&amp;#39;ve found so far is to use the catch block to send an error message by email, which works because you&amp;#39;re not changing anything in the form.  But it still seems like a second rate solution because the user may still wonder why her changes are not working.
&lt;p&gt;
Thanks, in advance,&lt;br /&gt;
Bruce</description></item></channel></rss>