Switching view in a catch block - InfoPath Dev
in

InfoPath Dev

Switching view in a catch block

Last post 07-05-2013 11:43 AM by BAltner. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 07-05-2013 11:43 AM

    Switching view in a catch block

    Greetings: I may be trying to do the impossible, but I've seen some really clever solutions posted to this forum so I decided to ask for help before giving up. Here's the situation:

    1. SharePoint 2010 forms library with the "Content Approval" 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.

    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't see it and might try to edit the one he can see, which throws a System.Net.WebException.

    3. I catch the exception and try to switch views to show an error message (this is web-based so I don't have a MessageBox) but even the view does not switch using this.ViewInfos.SwitchView("ErrorMessage").

    4. Debugging shows me that the this.CurrentView.ViewInfo.Name has inded changed from default to "ErrorMessage" but that is apprently ignored.

    5. I tried to fix this by setting a field value, "exceptionThrown" to TRUE and switching it via this.SetDefaultView("ErrorMessage") in the FormEventsLoading method, but this doesn't work either because if you can't edit the form you can't set a flag, so it is always FALSE and the view doesn't switch.

    The best workaround that I've found so far is to use the catch block to send an error message by email, which works because you'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.

    Thanks, in advance,
    Bruce

    Filed under: ,
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.